Class AbstractSetValuedMap<K,V>
- java.lang.Object
-
- org.apache.commons.collections4.multimap.AbstractMultiValuedMap<K,V>
-
- org.apache.commons.collections4.multimap.AbstractSetValuedMap<K,V>
-
- Type Parameters:
K- the type of the keys in this mapV- the type of the values in this map
- All Implemented Interfaces:
MultiValuedMap<K,V>,SetValuedMap<K,V>
- Direct Known Subclasses:
HashSetValuedHashMap
public abstract class AbstractSetValuedMap<K,V> extends AbstractMultiValuedMap<K,V> implements SetValuedMap<K,V>
Abstract implementation of theSetValuedMapinterface to simplify the creation of subclass implementations.Subclasses specify a Map implementation to use as the internal storage and the Set implementation to use as values.
- Since:
- 4.1
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSetValuedMap()Constructor needed for subclass serialisation.protectedAbstractSetValuedMap(java.util.Map<K,? extends java.util.Set<V>> map)A constructor that wraps, not copies
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.util.Set<V>createCollection()Creates a new value collection using the provided factory.java.util.Set<V>get(K key)Gets the set of values associated with the specified key.protected java.util.Map<K,java.util.Set<V>>getMap()Gets the map being wrapped.java.util.Set<V>remove(java.lang.Object key)Removes all values associated with the specified key.-
Methods inherited from class org.apache.commons.collections4.multimap.AbstractMultiValuedMap
asMap, clear, containsKey, containsMapping, containsValue, doReadObject, doWriteObject, entries, equals, hashCode, isEmpty, keys, keySet, mapIterator, put, putAll, putAll, putAll, removeMapping, setMap, size, toString, values
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
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
-
getMap
protected java.util.Map<K,java.util.Set<V>> getMap()
Description copied from class:AbstractMultiValuedMapGets the map being wrapped.- Overrides:
getMapin classAbstractMultiValuedMap<K,V>- Returns:
- the wrapped map
-
createCollection
protected abstract java.util.Set<V> createCollection()
Creates a new value collection using the provided factory.- Specified by:
createCollectionin classAbstractMultiValuedMap<K,V>- Returns:
- a new list
-
get
public java.util.Set<V> get(K key)
Gets the set of values associated with the specified key. This would return an empty set in case the mapping is not present- Specified by:
getin interfaceMultiValuedMap<K,V>- Specified by:
getin interfaceSetValuedMap<K,V>- Overrides:
getin classAbstractMultiValuedMap<K,V>- Parameters:
key- the key to retrieve- Returns:
- the
Setof values, will return an emptySetfor no mapping
-
remove
public java.util.Set<V> remove(java.lang.Object key)
Removes all values associated with the specified key.A subsequent
get(Object)would return an empty set.- Specified by:
removein interfaceMultiValuedMap<K,V>- Specified by:
removein interfaceSetValuedMap<K,V>- Overrides:
removein classAbstractMultiValuedMap<K,V>- Parameters:
key- the key to remove values from- Returns:
- the
Setof values removed, will return an empty, unmodifiable set for no mapping found.
-
-