Package org.apache.commons.collections4
Interface ListValuedMap<K,V>
-
- Type Parameters:
K
- the type of the keys in this mapV
- the type of the values in this map
- All Superinterfaces:
MultiValuedMap<K,V>
- All Known Implementing Classes:
AbstractListValuedMap
,ArrayListValuedHashMap
public interface ListValuedMap<K,V> extends MultiValuedMap<K,V>
Defines a map that holds a list of values against each key.A
ListValuedMap
is a Map with slightly different semantics:- Putting a value into the map will add the value to a
List
at that key. - Getting a value will return a
List
, holding all the values put to that key.
- Since:
- 4.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<V>
get(K key)
Gets the list of values associated with the specified key.java.util.List<V>
remove(java.lang.Object key)
Removes all values associated with the specified key.-
Methods inherited from interface org.apache.commons.collections4.MultiValuedMap
asMap, clear, containsKey, containsMapping, containsValue, entries, isEmpty, keys, keySet, mapIterator, put, putAll, putAll, putAll, removeMapping, size, values
-
-
-
-
Method Detail
-
get
java.util.List<V> get(K key)
Gets the list of values associated with the specified key.This method will return an empty list if
MultiValuedMap.containsKey(Object)
returnsfalse
. Changes to the returned list will update the underlyingListValuedMap
and vice-versa.- Specified by:
get
in interfaceMultiValuedMap<K,V>
- Parameters:
key
- the key to retrieve- Returns:
- the
List
of values, implementations should return an emptyList
for no mapping - Throws:
java.lang.NullPointerException
- if the key is null and null keys are invalid
-
remove
java.util.List<V> remove(java.lang.Object key)
Removes all values associated with the specified key.The returned list may be modifiable, but updates will not be propagated to this list-valued map. In case no mapping was stored for the specified key, an empty, unmodifiable list will be returned.
- Specified by:
remove
in interfaceMultiValuedMap<K,V>
- Parameters:
key
- the key to remove values from- Returns:
- the
List
of values removed, implementations typically return an empty, unmodifiableList
for no mapping found - Throws:
java.lang.UnsupportedOperationException
- if the map is unmodifiablejava.lang.NullPointerException
- if the key is null and null keys are invalid
-
-