Package org.miaixz.bus.core.center.map
Class TransMap<K,V>
java.lang.Object
org.miaixz.bus.core.center.map.MapWrapper<K,V>
org.miaixz.bus.core.center.map.TransMap<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Map.Entry<K,,V>> Map<K,,V> Wrapper<Map<K,V>>
- Direct Known Subclasses:
CustomKeyMap,FuncMap
自定义键和值转换的的Map
继承此类后,通过实现
customKey(Object)和customValue(Object),按照给定规则加入到map或获取值。- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) booleancontainsKey(Object key) protected abstract K自定义键protected abstract VcustomValue(Object value) 自定义值getOrDefault(Object key, V defaultValue) voidputIfAbsent(K key, V value) booleanbooleanMethods inherited from class org.miaixz.bus.core.center.map.MapWrapper
clear, clone, containsValue, entrySet, equals, forEach, getRaw, hashCode, isEmpty, iterator, keySet, replaceAll, size, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TransMap
构造 通过传入一个Map从而确定Map的类型,子类需创建一个空的Map,而非传入一个已有Map,否则值可能会被修改- Parameters:
mapFactory- 空Map创建工厂
-
TransMap
构造 通过传入一个Map从而确定Map的类型,子类需创建一个空的Map,而非传入一个已有Map,否则值可能会被修改- Parameters:
emptyMap- Map 被包装的Map,必须为空Map,否则自定义key会无效
-
-
Method Details
-
get
-
put
-
putAll
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classMapWrapper<K,V>
-
remove
-
remove
-
replace
-
replace
-
getOrDefault
- Specified by:
getOrDefaultin interfaceMap<K,V> - Overrides:
getOrDefaultin classMapWrapper<K,V>
-
computeIfPresent
- Specified by:
computeIfPresentin interfaceMap<K,V> - Overrides:
computeIfPresentin classMapWrapper<K,V>
-
compute
-
merge
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceMap<K,V> - Overrides:
putIfAbsentin classMapWrapper<K,V>
-
computeIfAbsent
- Specified by:
computeIfAbsentin interfaceMap<K,V> - Overrides:
computeIfAbsentin classMapWrapper<K,V>
-
customKey
自定义键- Parameters:
key- KEY- Returns:
- 自定义KEY
-
customValue
自定义值- Parameters:
value- 值- Returns:
- 自定义值
-