Class AbstractCollValueMap<K,V>
java.lang.Object
org.miaixz.bus.core.center.map.MapWrapper<K,Collection<V>>
org.miaixz.bus.core.center.map.multi.AbstractCollValueMap<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Map.Entry<K,,Collection<V>>> Map<K,,Collection<V>> MultiValueMap<K,,V> Wrapper<Map<K,,Collection<V>>> Provider
- Direct Known Subclasses:
CollectionValueMap,ListValueMap,SetValueMap
public abstract class AbstractCollValueMap<K,V>
extends MapWrapper<K,Collection<V>>
implements MultiValueMap<K,V>
MultiValueMap的基本实现- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int默认集合初始大小 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected基于HashMap构造一个多值映射集合protectedAbstractCollValueMap(Supplier<Map<K, Collection<V>>> mapFactory) 使用mapFactory创建的集合构造一个多值映射Map集合protectedAbstractCollValueMap(Map<K, Collection<V>> map) 基于HashMap构造一个多值映射集合 -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Collection<V> 创建集合 此方法用于创建在putValue后追加值所在的集合,子类实现此方法创建不同类型的集合filterAllValues(BiPredicate<K, V> filter) 根据条件过滤所有值集合中的值,并以新值生成新的值集合,新集合中的值集合类型与当前实例的默认值集合类型保持一致booleanputAllValues(K key, Collection<V> coll) 将集合中的全部元素对追加到指定键对应的值集合中,效果等同于:boolean向指定键对应的值集合追加值,效果等同于:booleanremoveAllValues(K key, Collection<V> values) 将一批值从指定键下的值集合中删除booleanremoveValue(K key, V value) 将值从指定键下的值集合中删除replaceAllValues(BiFunction<K, V, V> operate) 根据条件替换所有值集合中的值,并以新值生成新的值集合,新集合中的值集合类型与当前实例的默认值集合类型保持一致Methods inherited from class org.miaixz.bus.core.center.map.MapWrapper
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, getRaw, hashCode, isEmpty, iterator, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from interface org.miaixz.bus.core.center.map.multi.MultiValueMap
allForEach, allValues, filterAllValues, getValue, getValues, put, putAll, putAllValues, putValues, removeValues, replaceAllValues, size
-
Field Details
-
DEFAULT_COLLECTION_INITIAL_CAPACITY
protected static final int DEFAULT_COLLECTION_INITIAL_CAPACITY默认集合初始大小- See Also:
-
-
Constructor Details
-
Method Details
-
putAllValues
将集合中的全部元素对追加到指定键对应的值集合中,效果等同于:coll.forEach(t -> map.putValue(data, t))- Specified by:
putAllValuesin interfaceMultiValueMap<K,V> - Parameters:
key- 键coll- 待添加的值集合- Returns:
- 是否成功添加
-
putValue
向指定键对应的值集合追加值,效果等同于:map.computeIfAbsent(data, k -> new Collection()).add(value)- Specified by:
putValuein interfaceMultiValueMap<K,V> - Parameters:
key- 键value- 值- Returns:
- 是否成功添加
-
removeValue
将值从指定键下的值集合中删除- Specified by:
removeValuein interfaceMultiValueMap<K,V> - Parameters:
key- 键value- 值- Returns:
- 是否成功删除
-
removeAllValues
将一批值从指定键下的值集合中删除- Specified by:
removeAllValuesin interfaceMultiValueMap<K,V> - Parameters:
key- 键values- 值- Returns:
- 是否成功删除
-
filterAllValues
根据条件过滤所有值集合中的值,并以新值生成新的值集合,新集合中的值集合类型与当前实例的默认值集合类型保持一致- Specified by:
filterAllValuesin interfaceMultiValueMap<K,V> - Parameters:
filter- 判断方法- Returns:
- 当前实例
-
replaceAllValues
根据条件替换所有值集合中的值,并以新值生成新的值集合,新集合中的值集合类型与当前实例的默认值集合类型保持一致- Specified by:
replaceAllValuesin interfaceMultiValueMap<K,V> - Parameters:
operate- 替换方法- Returns:
- 当前实例
-
createCollection
创建集合 此方法用于创建在putValue后追加值所在的集合,子类实现此方法创建不同类型的集合- Returns:
Collection
-