Interface CloneStrategy
public interface CloneStrategy
Strategy interface for object cloning (SPI)
对象克隆策略接口(SPI)
Implementations provide different cloning approaches such as reflection-based, serialization-based, or Unsafe-based cloning.
实现提供不同的克隆方法,如基于反射、基于序列化或基于Unsafe的克隆。
Features | 主要功能:
- Strategy naming - 策略命名
- Type support checking - 类型支持检查
- Priority ordering - 优先级排序
Usage Examples | 使用示例:
public class CustomStrategy implements CloneStrategy {
@Override
public String name() {
return "custom";
}
@Override
public <T> T clone(T original, CloneContext context) {
// Custom cloning logic
}
}
Security | 安全性:
- Thread-safe: Implementation dependent - 线程安全: 取决于实现
- 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, CloneContext context) Clones the object using this strategy 使用此策略克隆对象name()Gets the name of this strategy 获取此策略的名称default intpriority()Gets the priority of this strategy 获取此策略的优先级default booleanChecks if this strategy supports the given type 检查此策略是否支持给定类型
-
Method Details
-
name
-
clone
Clones the object using this strategy 使用此策略克隆对象- Type Parameters:
T- the object type | 对象类型- Parameters:
original- the original object | 原始对象context- the clone context | 克隆上下文- Returns:
- the cloned object | 克隆的对象
-
priority
default int priority()Gets the priority of this strategy 获取此策略的优先级Lower values indicate higher priority. Default is 100.
较小的值表示较高的优先级。默认值为100。
- Returns:
- the priority | 优先级
-
supports
Checks if this strategy supports the given type 检查此策略是否支持给定类型- Parameters:
type- the type to check | 要检查的类型- Returns:
- true if supported | 如果支持返回true
-