K - The type of key objectsV - The type of value objectspublic interface MultiValueMap<K,V>
extends java.util.Map<K,V>
Unlike other multi map types, this type is optimized for the case where there is only one value for a key.
The map acts just like a normal Map, but has extra methods for getting all values for a key.
All implementations of this type are immutable. Mutating operations throw UnsupportedOperationException.
Where there is multiple values for a given key, retrieving a single value will return the first value, where the first value is intrinsic to the service in which the map is being used.
| Modifier and Type | Method and Description |
|---|---|
com.google.common.collect.ListMultimap<K,V> |
asMultimap() |
void |
clear()
Throws
UnsupportedOperationException. |
static <K,V> MultiValueMap<K,V> |
empty() |
V |
get(java.lang.Object key)
Get the first value for the key, or
null if there are no values for the key. |
java.util.Map<K,java.util.List<V>> |
getAll()
Returns a new view of the map where each map value is a list of all the values for the given key (i.e.
|
java.util.List<V> |
getAll(K key)
All of the values for the given key.
|
V |
put(K key,
V value)
Throws
UnsupportedOperationException. |
void |
putAll(java.util.Map<? extends K,? extends V> m)
Throws
UnsupportedOperationException. |
V |
remove(java.lang.Object key)
Throws
UnsupportedOperationException. |
static <K,V> MultiValueMap<K,V> empty()
java.util.List<V> getAll(K key)
The returned list is immutable.
key - The key to return all values ofjava.util.Map<K,java.util.List<V>> getAll()
The returned map is immutable.
@Nullable V get(java.lang.Object key)
null if there are no values for the key.V remove(java.lang.Object key)
UnsupportedOperationException.
void clear()
UnsupportedOperationException.