K - 键类型V - 值类型public abstract class AbsCollValueMap<K,V> extends MapWrapper<K,Collection<V>> implements MultiValueMap<K,V>
MultiValueMap的基本实现CollectionValueMap,
SetValueMap,
ListValueMap,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_COLLECTION_INITIAL_CAPACITY
默认集合初始大小
|
DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR| Modifier | Constructor and Description |
|---|---|
protected |
AbsCollValueMap()
基于
HashMap构造一个多值映射集合 |
protected |
AbsCollValueMap(Map<K,Collection<V>> map)
基于
HashMap构造一个多值映射集合 |
protected |
AbsCollValueMap(Supplier<Map<K,Collection<V>>> mapFactory)
使用
mapFactory创建的集合构造一个多值映射Map集合 |
| Modifier and Type | Method and Description |
|---|---|
protected abstract Collection<V> |
createCollection()
创建集合
此方法用于创建在putValue后追加值所在的集合,子类实现此方法创建不同类型的集合 |
MultiValueMap<K,V> |
filterAllValues(BiPredicate<K,V> filter)
根据条件过滤所有值集合中的值,并以新值生成新的值集合,新集合中的值集合类型与当前实例的默认值集合类型保持一致
|
boolean |
putAllValues(K key,
Collection<V> coll)
将集合中的全部元素对追加到指定键对应的值集合中,效果等同于:
coll.forEach(t -> map.putValue(key, t))
|
boolean |
putValue(K key,
V value)
向指定键对应的值集合追加值,效果等同于:
map.computeIfAbsent(key, k -> new Collection()).add(value)
|
boolean |
removeAllValues(K key,
Collection<V> values)
将一批值从指定键下的值集合中删除
|
boolean |
removeValue(K key,
V value)
将值从指定键下的值集合中删除
|
MultiValueMap<K,V> |
replaceAllValues(BiFunction<K,V,V> operate)
根据条件替换所有值集合中的值,并以新值生成新的值集合,新集合中的值集合类型与当前实例的默认值集合类型保持一致
|
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, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitallForEach, allValues, filterAllValues, getValue, getValues, put, putAll, putAllValues, putValues, removeValues, replaceAllValues, sizeclear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesforEach, spliteratorprotected static final int DEFAULT_COLLECTION_INITIAL_CAPACITY
protected AbsCollValueMap(Supplier<Map<K,Collection<V>>> mapFactory)
mapFactory创建的集合构造一个多值映射Map集合mapFactory - 生成集合的工厂方法protected AbsCollValueMap(Map<K,Collection<V>> map)
HashMap构造一个多值映射集合map - 提供初始数据的集合protected AbsCollValueMap()
HashMap构造一个多值映射集合public boolean putAllValues(K key, Collection<V> coll)
coll.forEach(t -> map.putValue(key, t))
putAllValues in interface MultiValueMap<K,V>key - 键coll - 待添加的值集合public boolean putValue(K key, V value)
map.computeIfAbsent(key, k -> new Collection()).add(value)
putValue in interface MultiValueMap<K,V>key - 键value - 值public boolean removeValue(K key, V value)
removeValue in interface MultiValueMap<K,V>key - 键value - 值public boolean removeAllValues(K key, Collection<V> values)
removeAllValues in interface MultiValueMap<K,V>key - 键values - 值public MultiValueMap<K,V> filterAllValues(BiPredicate<K,V> filter)
filterAllValues in interface MultiValueMap<K,V>filter - 判断方法public MultiValueMap<K,V> replaceAllValues(BiFunction<K,V,V> operate)
replaceAllValues in interface MultiValueMap<K,V>operate - 替换方法protected abstract Collection<V> createCollection()
CollectionCopyright © 2025. All rights reserved.