Class PropertyAccessors
java.lang.Object
cloud.opencode.base.reflect.accessor.PropertyAccessors
Property Accessors Factory
属性访问器工厂
Factory for creating property accessors with different strategies.
用不同策略创建属性访问器的工厂。
Features | 主要功能:
- Multiple access strategies (Field, Bean, MethodHandle, VarHandle, Lambda) - 多种访问策略
- Auto-strategy selection - 自动策略选择
- Bulk accessor creation - 批量访问器创建
Usage Examples | 使用示例:
// Auto-select best strategy
PropertyAccessor<User> accessor = PropertyAccessors.create(User.class, "name");
// Create all accessors for a class
Map<String, PropertyAccessor<User>> accessors = PropertyAccessors.createAll(User.class);
Security | 安全性:
- Thread-safe: Yes (stateless factory) - 线程安全: 是(无状态工厂)
- Null-safe: No (caller must ensure non-null arguments) - 空值安全: 否(调用方须确保非空参数)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAccess strategy enumeration 访问策略枚举 -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> PropertyAccessor<T> Creates a property accessor with auto strategy 以自动策略创建属性访问器static <T> PropertyAccessor<T> create(Class<T> clazz, String propertyName, PropertyAccessors.Strategy strategy) Creates a property accessor with specified strategy 以指定策略创建属性访问器static <T> Map<String, PropertyAccessor<T>> Creates all property accessors for a class 为类创建所有属性访问器static <T> Map<String, PropertyAccessor<T>> createAll(Class<T> clazz, PropertyAccessors.Strategy strategy) Creates all property accessors for a class with strategy 以策略为类创建所有属性访问器static <T> Map<String, BeanAccessor<T>> createBeanAccessors(Class<T> clazz) Creates bean-based accessors for all properties 为所有属性创建基于bean的访问器static <T> Map<String, FieldAccessor<T>> createFieldAccessors(Class<T> clazz) Creates field-based accessors for all fields 为所有字段创建基于字段的访问器static <T> Map<String, VarHandleAccessor<T>> createVarHandleAccessors(Class<T> clazz) Creates VarHandle-based accessors for all fields 为所有字段创建基于VarHandle的访问器
-
Method Details
-
create
Creates a property accessor with auto strategy 以自动策略创建属性访问器- Type Parameters:
T- the target type | 目标类型- Parameters:
clazz- the class | 类propertyName- the property name | 属性名- Returns:
- the accessor | 访问器
-
create
public static <T> PropertyAccessor<T> create(Class<T> clazz, String propertyName, PropertyAccessors.Strategy strategy) Creates a property accessor with specified strategy 以指定策略创建属性访问器- Type Parameters:
T- the target type | 目标类型- Parameters:
clazz- the class | 类propertyName- the property name | 属性名strategy- the strategy | 策略- Returns:
- the accessor | 访问器
-
createAll
Creates all property accessors for a class 为类创建所有属性访问器- Type Parameters:
T- the target type | 目标类型- Parameters:
clazz- the class | 类- Returns:
- map of property name to accessor | 属性名到访问器的映射
-
createAll
public static <T> Map<String, PropertyAccessor<T>> createAll(Class<T> clazz, PropertyAccessors.Strategy strategy) Creates all property accessors for a class with strategy 以策略为类创建所有属性访问器- Type Parameters:
T- the target type | 目标类型- Parameters:
clazz- the class | 类strategy- the strategy | 策略- Returns:
- map of property name to accessor | 属性名到访问器的映射
-
createFieldAccessors
Creates field-based accessors for all fields 为所有字段创建基于字段的访问器- Type Parameters:
T- the target type | 目标类型- Parameters:
clazz- the class | 类- Returns:
- map of field name to accessor | 字段名到访问器的映射
-
createBeanAccessors
Creates bean-based accessors for all properties 为所有属性创建基于bean的访问器- Type Parameters:
T- the target type | 目标类型- Parameters:
clazz- the class | 类- Returns:
- map of property name to accessor | 属性名到访问器的映射
-
createVarHandleAccessors
Creates VarHandle-based accessors for all fields 为所有字段创建基于VarHandle的访问器- Type Parameters:
T- the target type | 目标类型- Parameters:
clazz- the class | 类- Returns:
- map of field name to accessor | 字段名到访问器的映射
-