Class MapHandler
java.lang.Object
cloud.opencode.base.deepclone.handler.MapHandler
- All Implemented Interfaces:
TypeHandler<Map<?,?>>
Handler for cloning Map types
Map类型克隆处理器
Handles all Map types including HashMap, TreeMap, LinkedHashMap, and concurrent implementations. Both keys and values can be deep cloned.
处理所有Map类型,包括HashMap、TreeMap、LinkedHashMap和并发实现。 键和值都可以被深度克隆。
Supported Types | 支持的类型:
- HashMap, LinkedHashMap, TreeMap, WeakHashMap
- Hashtable, IdentityHashMap, EnumMap
- ConcurrentHashMap, ConcurrentSkipListMap
Features | 主要功能:
- Deep clone all Map types - 深度克隆所有Map类型
- Preserves original map type - 保留原始Map类型
- Recursive key and value cloning - 递归键值克隆
Usage Examples | 使用示例:
MapHandler handler = new MapHandler();
Map<String, User> cloned = (Map<String, User>) handler.clone(originalMap, 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 TypeMethodDescriptionMap<?, ?> clone(Map<?, ?> original, Cloner cloner, CloneContext context) Clones the object 克隆对象<K,V> Map <K, V> cloneDeep(Map<K, V> map, Cloner cloner, CloneContext context) Clones a Map with deep cloning of both keys and values 克隆Map并深度克隆键和值<K,V> Map <K, V> cloneValues(Map<K, V> map, Cloner cloner, CloneContext context) Clones a Map with only values deep cloned (keys are shared) 克隆Map并仅深度克隆值(键共享)<K,V> Map <K, V> createInstance(Class<?> type, int size) Creates an instance of the specified map type 创建指定Map类型的实例intpriority()Gets the priority of this handler 获取此处理器的优先级booleanChecks if this handler supports the given type 检查此处理器是否支持给定类型
-
Constructor Details
-
MapHandler
public MapHandler()
-
-
Method Details
-
clone
Description copied from interface:TypeHandlerClones the object 克隆对象- Specified by:
clonein interfaceTypeHandler<Map<?,?>> - Parameters:
original- the original object | 原始对象cloner- the cloner for recursive cloning | 用于递归克隆的克隆器context- the clone context | 克隆上下文- Returns:
- the cloned object | 克隆的对象
-
cloneDeep
Clones a Map with deep cloning of both keys and values 克隆Map并深度克隆键和值- Type Parameters:
K- the key type | 键类型V- the value type | 值类型- Parameters:
map- the original map | 原始Mapcloner- the cloner | 克隆器context- the context | 上下文- Returns:
- the cloned map | 克隆的Map
-
cloneValues
Clones a Map with only values deep cloned (keys are shared) 克隆Map并仅深度克隆值(键共享)- Type Parameters:
K- the key type | 键类型V- the value type | 值类型- Parameters:
map- the original map | 原始Mapcloner- the cloner | 克隆器context- the context | 上下文- Returns:
- the cloned map | 克隆的Map
-
createInstance
-
supports
Description copied from interface:TypeHandlerChecks if this handler supports the given type 检查此处理器是否支持给定类型- Specified by:
supportsin interfaceTypeHandler<Map<?,?>> - 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<Map<?,?>> - Returns:
- the priority | 优先级
-