Class RecordComponent
java.lang.Object
cloud.opencode.base.reflect.record.RecordComponent
Record Component Wrapper
Record组件包装器
Wraps a java.lang.reflect.RecordComponent with additional utilities.
用额外工具包装java.lang.reflect.RecordComponent。
Features | 主要功能:
- Component type and name access - 组件类型和名称访问
- Accessor method invocation - 访问器方法调用
- Annotation access on components - 组件上的注解访问
Usage Examples | 使用示例:
List<RecordComponent> components = OpenRecord.getComponents(User.class);
RecordComponent comp = components.get(0);
String name = comp.getName();
Object value = comp.getValue(userRecord);
Security | 安全性:
- Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
- Null-safe: No (component must be non-null) - 空值安全: 否(组件须非空)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRecordComponent(RecordComponent component) Creates a RecordComponent wrapper 创建RecordComponent包装器 -
Method Summary
Modifier and TypeMethodDescriptionboolean<A extends Annotation>
Optional<A> findAnnotation(Class<A> annotationClass) Finds an annotation (Optional) 查找注解(Optional)Gets the accessor method 获取访问器方法<A extends Annotation>
AgetAnnotation(Class<A> annotationClass) Gets an annotation from this component 从此组件获取注解Gets all annotations on this component 获取此组件上的所有注解Class<?> Gets the declaring record class 获取声明的record类Gets the generic type 获取泛型类型intgetIndex()Gets the index of this component 获取此组件的索引getName()Gets the component name 获取组件名称Class<?> getType()Gets the component type 获取组件类型Gets the value from a record instance 从record实例获取值<T> TGets the value with type 获取值(带类型)booleanhasAnnotation(Class<? extends Annotation> annotationClass) Checks if annotation is present 检查注解是否存在inthashCode()booleanisArray()Checks if this component is an array 检查此组件是否为数组booleanChecks if this component is primitive 检查此组件是否为原始类型toString()unwrap()Gets the underlying RecordComponent 获取底层RecordComponent
-
Constructor Details
-
RecordComponent
Creates a RecordComponent wrapper 创建RecordComponent包装器- Parameters:
component- the underlying component | 底层组件
-
-
Method Details
-
getName
-
getType
-
getGenericType
-
getAccessor
-
getDeclaringClass
Gets the declaring record class 获取声明的record类- Returns:
- the declaring class | 声明类
-
getValue
-
getValue
-
getAnnotation
Gets an annotation from this component 从此组件获取注解- Type Parameters:
A- the annotation type | 注解类型- Parameters:
annotationClass- the annotation class | 注解类- Returns:
- the annotation or null | 注解或null
-
findAnnotation
Finds an annotation (Optional) 查找注解(Optional)- Type Parameters:
A- the annotation type | 注解类型- Parameters:
annotationClass- the annotation class | 注解类- Returns:
- Optional of annotation | 注解的Optional
-
hasAnnotation
Checks if annotation is present 检查注解是否存在- Parameters:
annotationClass- the annotation class | 注解类- Returns:
- true if present | 如果存在返回true
-
getAnnotations
Gets all annotations on this component 获取此组件上的所有注解- Returns:
- array of annotations | 注解数组
-
unwrap
Gets the underlying RecordComponent 获取底层RecordComponent- Returns:
- the underlying component | 底层组件
-
getIndex
public int getIndex()Gets the index of this component 获取此组件的索引- Returns:
- the index | 索引
-
isPrimitive
public boolean isPrimitive()Checks if this component is primitive 检查此组件是否为原始类型- Returns:
- true if primitive | 如果是原始类型返回true
-
isArray
public boolean isArray()Checks if this component is an array 检查此组件是否为数组- Returns:
- true if array | 如果是数组返回true
-
equals
-
hashCode
-
toString
-