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 | 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) |
int |
size() |
MultiMap<K,V> |
toImmutableMultiMap() |
Map<K,? extends List<V>> |
toListValuesMap() |
String |
toString() |
Collection<V> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
protected 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 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 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 © 2018. All rights reserved.