Interface PropertyAccessor<T>
- Type Parameters:
T- the target type | 目标类型
- All Known Implementing Classes:
BeanAccessor, FieldAccessor, LambdaAccessor, MethodHandleAccessor, VarHandleAccessor
public interface PropertyAccessor<T>
Property Accessor Interface
属性访问器接口
Unified interface for property read/write operations.
属性读写操作的统一接口。
Features | 主要功能:
- Property read/write operations - 属性读写操作
- Type and generic type access - 类型和泛型类型访问
- Readability/writability checking - 可读/可写检查
Usage Examples | 使用示例:
PropertyAccessor<User> accessor = PropertyAccessors.create(User.class, "name");
Object value = accessor.get(user);
accessor.set(user, "Alice");
Security | 安全性:
- Thread-safe: Depends on implementation - 线程安全: 取决于实现
- 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:
-
Method Summary
Modifier and TypeMethodDescriptionGets the property value 获取属性值default <V> VGets the property value with type 获取属性值(带类型)Gets the declaring class 获取声明类Gets the generic property type 获取泛型属性类型getName()Gets the property name 获取属性名default <V> VgetOrDefault(T target, V defaultValue) Gets property value or default 获取属性值或默认值Class<?> getType()Gets the property type 获取属性类型booleanChecks if property is readable 检查属性是否可读booleanChecks if property is writable 检查属性是否可写voidSets the property value 设置属性值default booleansetIfWritable(T target, Object value) Sets the property value if writable 如果可写则设置属性值
-
Method Details
-
getName
-
getType
-
getGenericType
-
getDeclaringClass
-
isReadable
boolean isReadable()Checks if property is readable 检查属性是否可读- Returns:
- true if readable | 如果可读返回true
-
isWritable
boolean isWritable()Checks if property is writable 检查属性是否可写- Returns:
- true if writable | 如果可写返回true
-
get
Gets the property value 获取属性值- Parameters:
target- the target object | 目标对象- Returns:
- the value | 值
- Throws:
IllegalStateException- if not readable | 如果不可读
-
get
-
set
Sets the property value 设置属性值- Parameters:
target- the target object | 目标对象value- the value | 值- Throws:
IllegalStateException- if not writable | 如果不可写
-
setIfWritable
-
getOrDefault
Gets property value or default 获取属性值或默认值- Type Parameters:
V- the value type | 值类型- Parameters:
target- the target object | 目标对象defaultValue- the default value | 默认值- Returns:
- the value or default | 值或默认值
-