Interface Cloner
- All Known Implementing Classes:
AbstractCloner, ReflectiveCloner, SerializingCloner, UnsafeCloner
public interface Cloner
Interface for object cloners
对象克隆器接口
Defines the contract for deep cloning objects. Implementations may use different strategies such as reflection, serialization, or Unsafe.
定义深度克隆对象的契约。实现可以使用不同的策略,如反射、序列化或Unsafe。
Features | 主要功能:
- Strategy-based cloning - 基于策略的克隆
- Context-aware cloning - 上下文感知克隆
- Type support checking - 类型支持检查
Usage Examples | 使用示例:
Cloner cloner = OpenClone.builder()
.reflective()
.maxDepth(50)
.build();
User cloned = cloner.clone(originalUser);
Security | 安全性:
- Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
- Since:
- JDK 25, opencode-base-deepclone V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T> Tclone(T original) Deep clones an object 深度克隆对象<T> Tclone(T original, CloneContext context) Deep clones an object using a specific context 使用特定上下文深度克隆对象Gets the name of the cloning strategy 获取克隆策略名称booleanChecks if this cloner supports the given type 检查此克隆器是否支持给定类型
-
Method Details
-
clone
<T> T clone(T original) Deep clones an object 深度克隆对象- Type Parameters:
T- the object type | 对象类型- Parameters:
original- the original object | 原始对象- Returns:
- the cloned object | 克隆的对象
-
clone
Deep clones an object using a specific context 使用特定上下文深度克隆对象- Type Parameters:
T- the object type | 对象类型- Parameters:
original- the original object | 原始对象context- the clone context | 克隆上下文- Returns:
- the cloned object | 克隆的对象
-
getStrategyName
String getStrategyName()Gets the name of the cloning strategy 获取克隆策略名称- Returns:
- the strategy name | 策略名称
-
supports
Checks if this cloner supports the given type 检查此克隆器是否支持给定类型- Parameters:
type- the type to check | 要检查的类型- Returns:
- true if supported | 如果支持返回true
-