Class CollectionHandler
java.lang.Object
cloud.opencode.base.deepclone.handler.CollectionHandler
- All Implemented Interfaces:
TypeHandler<Collection<?>>
Handler for cloning Collection types
集合类型克隆处理器
Handles all Collection types including List, Set, Queue, and their implementations. Elements are deep cloned recursively.
处理所有Collection类型,包括List、Set、Queue及其实现。元素会被递归深度克隆。
Supported Types | 支持的类型:
- ArrayList, LinkedList, Vector, Stack
- HashSet, LinkedHashSet, TreeSet
- ArrayDeque, PriorityQueue
- ConcurrentLinkedQueue, CopyOnWriteArrayList, etc.
Features | 主要功能:
- Deep clone all Collection types - 深度克隆所有Collection类型
- Preserves original collection type - 保留原始集合类型
- Recursive element cloning - 递归元素克隆
Usage Examples | 使用示例:
CollectionHandler handler = new CollectionHandler();
List<User> cloned = (List<User>) handler.clone(originalList, cloner, context);
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 TypeMethodDescriptionCollection<?> clone(Collection<?> original, Cloner cloner, CloneContext context) Clones the object 克隆对象<T> List<T> cloneList(List<T> list, Cloner cloner, CloneContext context) Clones a List 克隆List<T> Queue<T> cloneQueue(Queue<T> queue, Cloner cloner, CloneContext context) Clones a Queue 克隆Queue<T> Set<T> cloneSet(Set<T> set, Cloner cloner, CloneContext context) Clones a Set 克隆Set<T> Collection<T> createInstance(Class<?> type, int size) Creates an instance of the specified collection type 创建指定集合类型的实例intpriority()Gets the priority of this handler 获取此处理器的优先级booleanChecks if this handler supports the given type 检查此处理器是否支持给定类型
-
Constructor Details
-
CollectionHandler
public CollectionHandler()
-
-
Method Details
-
clone
Description copied from interface:TypeHandlerClones the object 克隆对象- Specified by:
clonein interfaceTypeHandler<Collection<?>>- Parameters:
original- the original object | 原始对象cloner- the cloner for recursive cloning | 用于递归克隆的克隆器context- the clone context | 克隆上下文- Returns:
- the cloned object | 克隆的对象
-
cloneList
Clones a List 克隆List- Type Parameters:
T- the element type | 元素类型- Parameters:
list- the original list | 原始列表cloner- the cloner | 克隆器context- the context | 上下文- Returns:
- the cloned list | 克隆的列表
-
cloneSet
Clones a Set 克隆Set- Type Parameters:
T- the element type | 元素类型- Parameters:
set- the original set | 原始集合cloner- the cloner | 克隆器context- the context | 上下文- Returns:
- the cloned set | 克隆的集合
-
cloneQueue
Clones a Queue 克隆Queue- Type Parameters:
T- the element type | 元素类型- Parameters:
queue- the original queue | 原始队列cloner- the cloner | 克隆器context- the context | 上下文- Returns:
- the cloned queue | 克隆的队列
-
createInstance
Creates an instance of the specified collection type 创建指定集合类型的实例- Type Parameters:
T- the element type | 元素类型- Parameters:
type- the collection type | 集合类型size- the expected size | 预期大小- Returns:
- the new collection instance | 新的集合实例
-
supports
Description copied from interface:TypeHandlerChecks if this handler supports the given type 检查此处理器是否支持给定类型- Specified by:
supportsin interfaceTypeHandler<Collection<?>>- 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<Collection<?>>- Returns:
- the priority | 优先级
-