Class BeanAccessor<T>
java.lang.Object
cloud.opencode.base.reflect.accessor.BeanAccessor<T>
- Type Parameters:
T- the target type | 目标类型
- All Implemented Interfaces:
PropertyAccessor<T>
Bean Property Accessor (via getter/setter)
Bean属性访问器(通过getter/setter)
Accesses properties via getter and setter methods.
通过getter和setter方法访问属性。
Features | 主要功能:
- Getter/setter-based property access - 基于getter/setter的属性访问
- Auto-discovery of getter/setter methods - 自动发现getter/setter方法
- Boolean property support (isXxx) - Boolean属性支持(isXxx)
Usage Examples | 使用示例:
BeanAccessor<User> accessor = BeanAccessor.of(User.class, "name");
String name = (String) accessor.get(user);
accessor.set(user, "Alice");
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 TypeMethodDescriptionbooleanGets the property value 获取属性值Gets the declaring class 获取声明类Gets the generic property type 获取泛型属性类型Gets the getter method 获取getter方法getName()Gets the property name 获取属性名Gets the setter method 获取setter方法Class<?> getType()Gets the property type 获取属性类型inthashCode()booleanChecks if property is readable 检查属性是否可读booleanChecks if property is writable 检查属性是否可写static <T> BeanAccessor<T> Creates a BeanAccessor for a property 为属性创建BeanAccessorvoidSets the property value 设置属性值toString()Methods inherited from interface PropertyAccessor
get, getOrDefault, setIfWritable
-
Constructor Details
-
BeanAccessor
Creates a BeanAccessor 创建BeanAccessor- Parameters:
name- the property name | 属性名declaringClass- the declaring class | 声明类getter- the getter method (can be null) | getter方法(可为null)setter- the setter method (can be null) | setter方法(可为null)
-
-
Method Details
-
of
Creates a BeanAccessor for a property 为属性创建BeanAccessor- Type Parameters:
T- the target type | 目标类型- Parameters:
clazz- the class | 类propertyName- the property name | 属性名- Returns:
- the accessor | 访问器
-
getGetter
Gets the getter method 获取getter方法- Returns:
- the getter or null | getter或null
-
getSetter
Gets the setter method 获取setter方法- Returns:
- the setter or null | setter或null
-
getName
Description copied from interface:PropertyAccessorGets the property name 获取属性名- Specified by:
getNamein interfacePropertyAccessor<T>- Returns:
- the property name | 属性名
-
getType
Description copied from interface:PropertyAccessorGets the property type 获取属性类型- Specified by:
getTypein interfacePropertyAccessor<T>- Returns:
- the property type | 属性类型
-
getGenericType
Description copied from interface:PropertyAccessorGets the generic property type 获取泛型属性类型- Specified by:
getGenericTypein interfacePropertyAccessor<T>- Returns:
- the generic type | 泛型类型
-
getDeclaringClass
Description copied from interface:PropertyAccessorGets the declaring class 获取声明类- Specified by:
getDeclaringClassin interfacePropertyAccessor<T>- Returns:
- the declaring class | 声明类
-
isReadable
public boolean isReadable()Description copied from interface:PropertyAccessorChecks if property is readable 检查属性是否可读- Specified by:
isReadablein interfacePropertyAccessor<T>- Returns:
- true if readable | 如果可读返回true
-
isWritable
public boolean isWritable()Description copied from interface:PropertyAccessorChecks if property is writable 检查属性是否可写- Specified by:
isWritablein interfacePropertyAccessor<T>- Returns:
- true if writable | 如果可写返回true
-
get
Description copied from interface:PropertyAccessorGets the property value 获取属性值- Specified by:
getin interfacePropertyAccessor<T>- Parameters:
target- the target object | 目标对象- Returns:
- the value | 值
-
set
Description copied from interface:PropertyAccessorSets the property value 设置属性值- Specified by:
setin interfacePropertyAccessor<T>- Parameters:
target- the target object | 目标对象value- the value | 值
-
equals
-
hashCode
-
toString
-