Class UnmodifiableMultiValuedMap<K,V>
- Type Parameters:
K- The type of key elementsV- The type of value elements
- All Implemented Interfaces:
Serializable,MultiValuedMap<K,,V> Unmodifiable
MultiValuedMap to ensure it can't be altered.
Attempts to modify it will result in an UnsupportedOperationException.
- Since:
- 4.1
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionMap<K, Collection<V>> asMap()Returns a view of this multivalued map as aMapfrom each distinct key to the non-empty collection of that key's associated values.voidclear()Always throwsUnsupportedOperationException.entries()Returns aCollectionview of the mappings contained in this multivalued map.Gets a view collection of the values associated with the specified key.keys()Returns aMultiSetview of the keys contained in this multivalued map.keySet()Returns aSetview of the keys contained in this multivalued map.Obtains aMapIteratorover this multivalued map.booleanAlways throwsUnsupportedOperationException.booleanAlways throwsUnsupportedOperationException.booleanAlways throwsUnsupportedOperationException.booleanputAll(MultiValuedMap<? extends K, ? extends V> map) Always throwsUnsupportedOperationException.Always throwsUnsupportedOperationException.booleanremoveMapping(Object key, Object item) Always throwsUnsupportedOperationException.static <K,V> UnmodifiableMultiValuedMap <K, V> unmodifiableMultiValuedMap(MultiValuedMap<? extends K, ? extends V> map) Factory method to create an unmodifiable MultiValuedMap.values()Gets aCollectionview of all values contained in this multivalued map.Methods inherited from class org.apache.commons.collections4.multimap.AbstractMultiValuedMapDecorator
containsKey, containsMapping, containsValue, decorated, equals, hashCode, isEmpty, size, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.collections4.MultiValuedMap
inverted
-
Method Details
-
unmodifiableMultiValuedMap
public static <K,V> UnmodifiableMultiValuedMap<K,V> unmodifiableMultiValuedMap(MultiValuedMap<? extends K, ? extends V> map) Factory method to create an unmodifiable MultiValuedMap.If the map passed in is already unmodifiable, it is returned.
- Type Parameters:
K- The type of key elementsV- The type of value elements- Parameters:
map- The map to decorate, may not be null- Returns:
- An unmodifiable MultiValuedMap
- Throws:
NullPointerException- if map is null
-
asMap
Description copied from interface:MultiValuedMapReturns a view of this multivalued map as aMapfrom each distinct key to the non-empty collection of that key's associated values.Note that
this.asMap().get(k)is equivalent tothis.get(k)only whenkis a key contained in the multivalued map; otherwise it returnsnullas opposed to an empty collection.Changes to the returned map or the collections that serve as its values will update the underlying multivalued map, and vice versa. The map does not support
putorputAll, nor do its entries supportsetValue.- Specified by:
asMapin interfaceMultiValuedMap<K,V> - Overrides:
asMapin classAbstractMultiValuedMapDecorator<K,V> - Returns:
- A map view of the mappings in this multivalued map.
-
clear
Always throwsUnsupportedOperationException.- Specified by:
clearin interfaceMultiValuedMap<K,V> - Overrides:
clearin classAbstractMultiValuedMapDecorator<K,V> - Throws:
UnsupportedOperationException- Always thrown.
-
entries
Description copied from interface:MultiValuedMapReturns aCollectionview of the mappings contained in this multivalued map.The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa.
- Specified by:
entriesin interfaceMultiValuedMap<K,V> - Overrides:
entriesin classAbstractMultiValuedMapDecorator<K,V> - Returns:
- A set view of the mappings contained in this map.
-
get
Description copied from interface:MultiValuedMapGets a view collection of the values associated with the specified key.This method will return an empty collection if
MultiValuedMap.containsKey(Object)returnsfalse. Changes to the returned collection will update the underlyingMultiValuedMapand vice-versa.- Specified by:
getin interfaceMultiValuedMap<K,V> - Overrides:
getin classAbstractMultiValuedMapDecorator<K,V> - Parameters:
key- The key to retrieve.- Returns:
- The
Collectionof values, implementations should return an empty collection for no mapping.
-
keys
Description copied from interface:MultiValuedMapReturns aMultiSetview of the keys contained in this multivalued map.The
MultiSet.getCount(Object)method of the returned multiset will give the same result a callingget(Object).size()for the same key.This multiset is backed by the map, so any changes in the map are reflected in the multiset.
- Specified by:
keysin interfaceMultiValuedMap<K,V> - Overrides:
keysin classAbstractMultiValuedMapDecorator<K,V> - Returns:
- A multiset view of the keys contained in this map.
-
keySet
Description copied from interface:MultiValuedMapReturns aSetview of the keys contained in this multivalued map.The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.
If the map is modified while an iteration over the set is in progress (except through the iterator's own
removeoperation), the result of the iteration is undefined. The set supports element removal, which removes the corresponding mapping from the map, via theIterator.remove,Set.remove,removeAll,retainAll, andclearoperations. It does not support theaddoraddAlloperations.- Specified by:
keySetin interfaceMultiValuedMap<K,V> - Overrides:
keySetin classAbstractMultiValuedMapDecorator<K,V> - Returns:
- A set view of the keys contained in this map.
-
mapIterator
Obtains aMapIteratorover this multivalued map.A map iterator is an efficient way of iterating over maps. There is no need to access the entries collection or use
Map.Entryobjects.The returned map iterator's
MapIterator.setValue(Object)method is not supported and will throw anUnsupportedOperationException.- Specified by:
mapIteratorin interfaceMultiValuedMap<K,V> - Overrides:
mapIteratorin classAbstractMultiValuedMapDecorator<K,V> - Returns:
- A map iterator.
-
put
Always throwsUnsupportedOperationException.- Specified by:
putin interfaceMultiValuedMap<K,V> - Overrides:
putin classAbstractMultiValuedMapDecorator<K,V> - Parameters:
key- Ignored.value- The value to add to the collection at the key.- Returns:
- true if the map changed as a result of this put operation, or false if the map already contained the key-value mapping and the collection type does not allow duplicate values, for example when using a Set.
- Throws:
UnsupportedOperationException- Always thrown.
-
putAll
Always throwsUnsupportedOperationException.- Specified by:
putAllin interfaceMultiValuedMap<K,V> - Overrides:
putAllin classAbstractMultiValuedMapDecorator<K,V> - Parameters:
key- Ignored.values- Ignored.- Returns:
- true if the map changed as a result of this operation.
- Throws:
UnsupportedOperationException- Always thrown.
-
putAll
Always throwsUnsupportedOperationException.- Specified by:
putAllin interfaceMultiValuedMap<K,V> - Overrides:
putAllin classAbstractMultiValuedMapDecorator<K,V> - Parameters:
map- Ignored.- Returns:
- true if the map changed as a result of this operation.
- Throws:
UnsupportedOperationException- Always thrown.
-
putAll
Always throwsUnsupportedOperationException.- Specified by:
putAllin interfaceMultiValuedMap<K,V> - Overrides:
putAllin classAbstractMultiValuedMapDecorator<K,V> - Parameters:
map- Ignored.- Returns:
- true if the map changed as a result of this operation.
- Throws:
UnsupportedOperationException- Always thrown.
-
remove
Always throwsUnsupportedOperationException.- Specified by:
removein interfaceMultiValuedMap<K,V> - Overrides:
removein classAbstractMultiValuedMapDecorator<K,V> - Parameters:
key- Ignored.- Returns:
- The values that were removed.
- Throws:
UnsupportedOperationException- Always thrown.
-
removeMapping
Always throwsUnsupportedOperationException.- Specified by:
removeMappingin interfaceMultiValuedMap<K,V> - Overrides:
removeMappingin classAbstractMultiValuedMapDecorator<K,V> - Parameters:
key- Ignored.item- Ignored.- Returns:
- true if the mapping was removed, false otherwise.
- Throws:
UnsupportedOperationException- Always thrown.
-
values
Description copied from interface:MultiValuedMapGets aCollectionview of all values contained in this multivalued map.Implementations typically return a collection containing the combination of values from all keys.
- Specified by:
valuesin interfaceMultiValuedMap<K,V> - Overrides:
valuesin classAbstractMultiValuedMapDecorator<K,V> - Returns:
- A collection view of the values contained in this multivalued map.
-