Class FieldMetadata

java.lang.Object
cloud.opencode.base.classloader.metadata.FieldMetadata

public final class FieldMetadata extends Object
Field Metadata - Immutable field information 字段元数据 - 不可变的字段信息

Represents field metadata read from class files without loading the class.

表示从类文件读取的字段元数据,无需加载类。

Features | 主要功能:

  • Field type and name - 字段类型和名称
  • Modifier information - 修饰符信息
  • Constant value access - 常量值访问
  • Annotation information - 注解信息

Usage Examples | 使用示例:

FieldMetadata field = classMetadata.fields().get(0);
String name = field.fieldName();
String type = field.fieldType();
boolean isStatic = field.isStatic();

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是 (不可变)
  • Null-safe: Yes - 空值安全: 是
Since:
JDK 25, opencode-base-classloader V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • FieldMetadata

      public FieldMetadata(String fieldName, String fieldType, int modifiers, Object constantValue, List<AnnotationMetadata> annotations)
      Create field metadata 创建字段元数据
      Parameters:
      fieldName - field name | 字段名
      fieldType - field type | 字段类型
      modifiers - modifier flags | 修饰符标志
      constantValue - constant value | 常量值
      annotations - field annotations | 字段注解
    • FieldMetadata

      public FieldMetadata(String fieldName, String fieldType, int modifiers, Object constantValue, List<AnnotationMetadata> annotations, String genericType)
      Create field metadata with generic type information 创建带有泛型类型信息的字段元数据
      Parameters:
      fieldName - field name | 字段名
      fieldType - field type | 字段类型
      modifiers - modifier flags | 修饰符标志
      constantValue - constant value | 常量值
      annotations - field annotations | 字段注解
      genericType - generic type (e.g. "List<String>") | 泛型类型
  • Method Details

    • fieldName

      public String fieldName()
      Get field name 获取字段名
      Returns:
      field name | 字段名
    • fieldType

      public String fieldType()
      Get field type 获取字段类型
      Returns:
      field type | 字段类型
    • modifiers

      public int modifiers()
      Get modifiers 获取修饰符
      Returns:
      modifier flags | 修饰符标志
    • constantValue

      public Object constantValue()
      Get constant value 获取常量值
      Returns:
      constant value or null | 常量值或 null
    • annotations

      public List<AnnotationMetadata> annotations()
      Get annotations 获取注解
      Returns:
      list of annotations | 注解列表
    • getGenericType

      public String getGenericType()
      Get generic type (e.g. "List<String>" instead of "List") 获取泛型类型(如 "List<String>" 而非 "List")
      Returns:
      generic type string or null if not generic | 泛型类型字符串,非泛型字段返回 null
    • isStatic

      public boolean isStatic()
      Check if static 检查是否为静态
      Returns:
      true if static | 是静态返回 true
    • isFinal

      public boolean isFinal()
      Check if final 检查是否为 final
      Returns:
      true if final | 是 final 返回 true
    • isTransient

      public boolean isTransient()
      Check if transient 检查是否为 transient
      Returns:
      true if transient | 是 transient 返回 true
    • isVolatile

      public boolean isVolatile()
      Check if volatile 检查是否为 volatile
      Returns:
      true if volatile | 是 volatile 返回 true
    • isPublic

      public boolean isPublic()
      Check if public 检查是否为 public
      Returns:
      true if public | 是 public 返回 true
    • isPrivate

      public boolean isPrivate()
      Check if private 检查是否为 private
      Returns:
      true if private | 是 private 返回 true
    • isProtected

      public boolean isProtected()
      Check if protected 检查是否为 protected
      Returns:
      true if protected | 是 protected 返回 true
    • hasConstantValue

      public boolean hasConstantValue()
      Check if has constant value 检查是否有常量值
      Returns:
      true if has constant value | 有常量值返回 true
    • hasAnnotation

      public boolean hasAnnotation(String annotationClassName)
      Check if has specified annotation 检查是否有指定注解
      Parameters:
      annotationClassName - annotation class name | 注解类名
      Returns:
      true if has annotation | 有注解返回 true
    • getAnnotation

      public Optional<AnnotationMetadata> getAnnotation(String annotationClassName)
      Get specified annotation 获取指定注解
      Parameters:
      annotationClassName - annotation class name | 注解类名
      Returns:
      optional annotation | 可选的注解
    • getSimpleTypeName

      public String getSimpleTypeName()
      Get simple field type name 获取简单字段类型名
      Returns:
      simple type name | 简单类型名
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object