Class RecordHandler
java.lang.Object
cloud.opencode.base.deepclone.handler.RecordHandler
- All Implemented Interfaces:
TypeHandler<Record>
Handler for cloning Record types
Record类型克隆处理器
Handles JDK 16+ Record classes by extracting component values, deep cloning them, and constructing a new Record instance.
通过提取组件值、深度克隆并构造新的Record实例来处理JDK 16+的Record类。
Usage Examples | 使用示例:
record Point(int x, int y, String label) {}
RecordHandler handler = new RecordHandler();
Point original = new Point(10, 20, "origin");
Point cloned = handler.cloneRecord(original, cloner, context);
Features | 主要功能:
- Record component extraction and cloning - Record组件提取和克隆
- Canonical constructor invocation - 规范构造函数调用
- JDK 16+ Record support - JDK 16+ Record支持
Security | 安全性:
- Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
- Since:
- JDK 25, opencode-base-deepclone V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone(Record original, Cloner cloner, CloneContext context) Clones the object 克隆对象<T extends Record>
TcloneRecord(T record, Cloner cloner, CloneContext context) Clones a Record 克隆Record<T extends Record>
TcreateInstance(Class<T> type, Object[] values) Creates a new Record instance with the given component values 使用给定的组件值创建新的Record实例Object[]getComponents(Record record) Gets the component values of a Record 获取Record的组件值intpriority()Gets the priority of this handler 获取此处理器的优先级booleanChecks if this handler supports the given type 检查此处理器是否支持给定类型
-
Constructor Details
-
RecordHandler
public RecordHandler()
-
-
Method Details
-
clone
Description copied from interface:TypeHandlerClones the object 克隆对象- Specified by:
clonein interfaceTypeHandler<Record>- Parameters:
original- the original object | 原始对象cloner- the cloner for recursive cloning | 用于递归克隆的克隆器context- the clone context | 克隆上下文- Returns:
- the cloned object | 克隆的对象
-
cloneRecord
Clones a Record 克隆Record- Type Parameters:
T- the record type | Record类型- Parameters:
record- the original record | 原始Recordcloner- the cloner | 克隆器context- the context | 上下文- Returns:
- the cloned record | 克隆的Record
-
getComponents
-
createInstance
Creates a new Record instance with the given component values 使用给定的组件值创建新的Record实例- Type Parameters:
T- the record type | Record类型- Parameters:
type- the record class | Record类values- the component values | 组件值- Returns:
- the new record instance | 新的Record实例
-
supports
Description copied from interface:TypeHandlerChecks if this handler supports the given type 检查此处理器是否支持给定类型- Specified by:
supportsin interfaceTypeHandler<Record>- Parameters:
type- the type to check | 要检查的类型- Returns:
- true if supported | 如果支持返回true
-
priority
public int priority()Description copied from interface:TypeHandlerGets the priority of this handler 获取此处理器的优先级Lower values indicate higher priority. Default is 100.
较小的值表示较高的优先级。默认值为100。
- Specified by:
priorityin interfaceTypeHandler<Record>- Returns:
- the priority | 优先级
-