Class PropertyDescriptor

java.lang.Object
cloud.opencode.base.core.bean.PropertyDescriptor

public final class PropertyDescriptor extends Object
Bean Property Descriptor - Describes a single bean property Bean 属性描述符 - 描述单个 Bean 属性

Encapsulates property metadata including name, type, getter, setter, and field.

封装属性元数据,包括名称、类型、Getter、Setter 和字段。

Features | 主要功能:

  • Property metadata (name, type, readable, writable) - 属性元数据
  • Value get/set operations - 值读写操作
  • Generic type information - 泛型类型信息
  • Annotation access (from method/field) - 注解访问

Usage Examples | 使用示例:

// Get property descriptor - 获取属性描述符
PropertyDescriptor pd = OpenBean.getPropertyDescriptor(User.class, "name").orElse(null);

// Check readable/writable - 检查可读/可写
boolean readable = pd.isReadable();
boolean writable = pd.isWritable();

// Get/Set value - 读写值
Object value = pd.getValue(user);
pd.setValue(user, newValue);

Security | 安全性:

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

  • Method Details

    • name

      public String name()
    • type

      public Class<?> type()
    • readMethod

      public Method readMethod()
    • writeMethod

      public Method writeMethod()
    • field

      public Field field()
    • isReadable

      public boolean isReadable()
      Checks whether this property is readable 是否可读
    • isWritable

      public boolean isWritable()
      Checks whether this property is writable 是否可写
    • hasField

      public boolean hasField()
      Checks whether this property has a corresponding field 是否有对应字段
    • getValue

      public Object getValue(Object bean)
      Gets the property value from the given bean 获取属性值
    • setValue

      public void setValue(Object bean, Object value)
      Sets the property value on the given bean 设置属性值
    • getGenericType

      public Type getGenericType()
      Gets the generic type of this property 获取泛型类型
    • getAnnotation

      public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
      Gets the specified annotation from this property 获取属性注解
    • hasAnnotation

      public boolean hasAnnotation(Class<? extends Annotation> annotationClass)
      Checks whether this property has the specified annotation 检查是否有指定注解
    • toString

      public String toString()
      Overrides:
      toString in class Object