Class PropertyDescriptor
java.lang.Object
cloud.opencode.base.reflect.bean.PropertyDescriptor
Property Descriptor
属性描述符
Describes a bean property with its getter, setter, and field.
描述bean属性及其getter、setter和字段。
Features | 主要功能:
- Getter/setter/field access - getter/setter/字段访问
- Property readability/writability checking - 属性可读/可写检查
- Annotation access on property - 属性上的注解访问
Usage Examples | 使用示例:
PropertyDescriptor desc = OpenBean.getPropertyDescriptors(User.class).get("name");
Object value = desc.getValue(user);
desc.setValue(user, "Alice");
boolean writable = desc.isWritable();
Security | 安全性:
- Thread-safe: No (not synchronized) - 线程安全: 否(未同步)
- Null-safe: No (caller must ensure non-null target) - 空值安全: 否(调用方须确保非空目标)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean<A extends Annotation>
Optional<A> getAnnotation(Class<A> annotationClass) Gets an annotation from this property 从此属性获取注解Class<?> Gets the declaring class 获取声明类getField()Gets the field 获取字段Gets the generic type 获取泛型类型getName()Gets the property name 获取属性名Class<?> Gets the property type 获取属性类型Gets the read method (getter) 获取读取方法(getter)Gets the property value 获取属性值Gets the write method (setter) 获取写入方法(setter)booleanhasAnnotation(Class<? extends Annotation> annotationClass) Checks if property has annotation 检查属性是否有注解inthashCode()booleanChecks if property is readable 检查属性是否可读booleanChecks if property is writable 检查属性是否可写voidSets the property value 设置属性值toString()
-
Constructor Details
-
PropertyDescriptor
public PropertyDescriptor(String name, Class<?> propertyType, Type genericType, Method readMethod, Method writeMethod, Field field, Class<?> declaringClass) Creates a PropertyDescriptor 创建PropertyDescriptor- Parameters:
name- the property name | 属性名propertyType- the property type | 属性类型genericType- the generic type | 泛型类型readMethod- the getter method (can be null) | getter方法(可为null)writeMethod- the setter method (can be null) | setter方法(可为null)field- the field (can be null) | 字段(可为null)declaringClass- the declaring class | 声明类
-
-
Method Details
-
getName
-
getPropertyType
-
getGenericType
-
getReadMethod
Gets the read method (getter) 获取读取方法(getter)- Returns:
- the read method or null | 读取方法或null
-
getWriteMethod
Gets the write method (setter) 获取写入方法(setter)- Returns:
- the write method or null | 写入方法或null
-
getField
-
getDeclaringClass
Gets the declaring class 获取声明类- Returns:
- the declaring class | 声明类
-
isReadable
public boolean isReadable()Checks if property is readable 检查属性是否可读- Returns:
- true if readable | 如果可读返回true
-
isWritable
public boolean isWritable()Checks if property is writable 检查属性是否可写- Returns:
- true if writable | 如果可写返回true
-
getValue
-
setValue
-
getAnnotation
Gets an annotation from this property 从此属性获取注解- Type Parameters:
A- the annotation type | 注解类型- Parameters:
annotationClass- the annotation class | 注解类- Returns:
- Optional of annotation | 注解的Optional
-
hasAnnotation
Checks if property has annotation 检查属性是否有注解- Parameters:
annotationClass- the annotation class | 注解类- Returns:
- true if has annotation | 如果有注解返回true
-
equals
-
hashCode
-
toString
-