Package org.miaixz.bus.core.center.map
Class MapWrapper<K,V>
java.lang.Object
org.miaixz.bus.core.center.map.MapWrapper<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Map.Entry<K,,V>> Map<K,,V> Wrapper<Map<K,,V>> Provider
- Direct Known Subclasses:
AbstractCollValueMap,BiMap,TolerantMap,TransMap
public class MapWrapper<K,V>
extends Object
implements Map<K,V>, Iterable<Map.Entry<K,V>>, Wrapper<Map<K,V>>, Serializable, Cloneable
Map包装类,通过包装一个已有Map实现特定功能。例如自定义Key的规则或Value规则
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionMapWrapper(Supplier<Map<K, V>> mapFactory) 构造 通过传入一个Map从而确定Map的类型,子类需创建一个空的Map,而非传入一个已有Map,否则值可能会被修改MapWrapper(Map<K, V> raw) 构造 -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()MapWrapper<K, V> clone()computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanvoidforEach(BiConsumer<? super K, ? super V> action) getOrDefault(Object key, V defaultValue) getRaw()获取原始的MapinthashCode()booleanisEmpty()iterator()keySet()voidputIfAbsent(K key, V value) booleanbooleanvoidreplaceAll(BiFunction<? super K, ? super V, ? extends V> function) intsize()toString()values()Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MapWrapper
构造 通过传入一个Map从而确定Map的类型,子类需创建一个空的Map,而非传入一个已有Map,否则值可能会被修改- Parameters:
mapFactory- 空Map创建工厂
-
MapWrapper
构造- Parameters:
raw- 被包装的Map,不允许为null- Throws:
NullPointerException- 当被包装的集合为null时抛出
-
-
Method Details
-
getRaw
获取原始的Map -
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
values
-
keySet
-
entrySet
-
iterator
-
equals
-
hashCode
public int hashCode() -
toString
-
forEach
-
replaceAll
- Specified by:
replaceAllin interfaceMap<K,V>
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceMap<K,V>
-
remove
-
replace
-
replace
-
computeIfAbsent
- Specified by:
computeIfAbsentin interfaceMap<K,V>
-
getOrDefault
- Specified by:
getOrDefaultin interfaceMap<K,V>
-
computeIfPresent
- Specified by:
computeIfPresentin interfaceMap<K,V>
-
compute
-
merge
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-