K - the type of keys maintained by this mapV - the type of mapped valuespublic class MultiMap<K,V> extends Object implements Map<K,V>, Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
MultiMap.StringMultiMap |
| Modifier and Type | Field and Description |
|---|---|
protected Map<K,LinkedList<V>> |
paramsMap |
| Constructor and Description |
|---|
MultiMap() |
MultiMap(Map<K,V> parametersMap) |
MultiMap(MultiMap<K,V> multiMap) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
static <K,V> MultiMap<K,V> |
emptyMultiMap()
Returns an empty multi-map (immutable).
|
List<Map.Entry<K,V>> |
entryList()
Returns a
List view of the mappings contained in this map, including an entry for each value associated to the same
key. |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object o) |
V |
get(Object key) |
List<V> |
getAll(Object key)
Returns the values to which the specified key is mapped.
|
int |
hashCode() |
boolean |
isEmpty() |
Set<K> |
keySet() |
void |
put(K key,
Collection<V> values)
Associates the specified value with the specified key in this map (optional operation).
|
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> aMap) |
void |
putAll(MultiMap<? extends K,? extends V> aMultiMap)
Similar to
putAll(Map), but instead of putting only the first value of each key, all the values are copied for each
key. |
V |
remove(Object key) |
List<V> |
removeAll(Object key)
Removes all elements associated with the provided
key. |
int |
size() |
MultiMap<K,V> |
toImmutableMultiMap() |
Map<K,? extends List<V>> |
toListValuesMap() |
static <T,K,U> Collector<T,?,MultiMap<K,U>> |
toMultiMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends U> valueMapper)
Returns a
Collector that accumulates elements into a Map whose keys and values are the result of applying the
provided mapping functions to the input elements. |
String |
toString() |
static <K,V> MultiMap<K,V> |
unmodifiableMultiMap(MultiMap<K,V> m)
Returns an unmodifiable view of the specified multi-map.
|
Collection<V> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllprotected Map<K,LinkedList<V>> paramsMap
public static <K,V> MultiMap<K,V> emptyMultiMap()
This example illustrates the type-safe way to obtain an empty map:
MultiMap<String, Stirng> s = MultiMap.emptyMultiMap();
K - the class of the map keysV - the class of the map valuespublic static <K,V> MultiMap<K,V> unmodifiableMultiMap(MultiMap<K,V> m)
The returned map will be serializable if the specified map is serializable.
K - the class of the map keysV - the class of the map valuesm - the multi-map for which an unmodifiable view is to be returned.public static <T,K,U> Collector<T,?,MultiMap<K,U>> toMultiMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper)
Collector that accumulates elements into a Map whose keys and values are the result of applying the
provided mapping functions to the input elements.
If the mapped keys contains duplicates (according to Object.equals(Object)), the value mapping function is applied to
each equal element, and the results are added to the values collection.
T - the type of the input elementsK - the output type of the key mapping functionU - the output type of the value mapping functionkeyMapper - a mapping function to produce keysvalueMapper - a mapping function to produce valuesCollector which collects elements into a MultiMap whose keys and values are the result of applying
mapping functions to the input elements.public boolean containsKey(Object key)
containsKey in interface Map<K,V>public boolean containsValue(Object value)
containsValue in interface Map<K,V>public List<V> getAll(Object key)
key - the key whose associated values are to be returnedpublic void put(K key, Collection<V> values)
key - key with which the specified values are to be associatedvalues - collection of values to be associated with the specified keypublic List<V> removeAll(Object key)
key.key - the key of the mappings to remove.key.public void putAll(MultiMap<? extends K,? extends V> aMultiMap)
putAll(Map), but instead of putting only the first value of each key, all the values are copied for each
key.aMultiMap - mappings to be stored in this mapClassCastException - if the class of a key or value in the specified map prevents it from being stored in this
mapNullPointerException - if the specified map is null, or if this map does not permit null keys or values, and the
specified map contains null keys or valuesIllegalArgumentException - if some property of a key or value in the specified map prevents it from being stored in
this mappublic List<Map.Entry<K,V>> entryList()
List view of the mappings contained in this map, including an entry for each value associated to the same
key.public boolean equals(Object o)
public int hashCode()
Copyright © 2023 MuleSoft, Inc.. All rights reserved.