Class UnmodifiableMultiValuedMap<K,V> 
- Type Parameters:
- K- the type of key elements
- V- 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 SummaryModifier 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()Removes all of the mappings from this map (optional operation).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.booleanAdds a key-value mapping to this multivalued map.booleanCopies all mappings from the specified map to this multivalued map (optional operation).booleanAdds a mapping to the specified key for all values contained in the given Iterable.booleanputAll(MultiValuedMap<? extends K, ? extends V> map) Copies all mappings from the specified map to this multivalued map (optional operation).Removes all values associated with the specified key.booleanremoveMapping(Object key, Object item) Removes a key-value mapping from the map.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.AbstractMultiValuedMapDecoratorcontainsKey, containsMapping, containsValue, decorated, equals, hashCode, isEmpty, size, toString
- 
Method Details- 
unmodifiableMultiValuedMappublic 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 elements
- V- 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
 
- 
asMapDescription 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 interface- MultiValuedMap<K,- V> 
- Overrides:
- asMapin class- AbstractMultiValuedMapDecorator<K,- V> 
- Returns:
- a map view of the mappings in this multivalued map
 
- 
clearDescription copied from interface:MultiValuedMapRemoves all of the mappings from this map (optional operation).The map will be empty after this call returns. - Specified by:
- clearin interface- MultiValuedMap<K,- V> 
- Overrides:
- clearin class- AbstractMultiValuedMapDecorator<K,- V> 
 
- 
entriesDescription 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 interface- MultiValuedMap<K,- V> 
- Overrides:
- entriesin class- AbstractMultiValuedMapDecorator<K,- V> 
- Returns:
- a set view of the mappings contained in this map
 
- 
getDescription 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 interface- MultiValuedMap<K,- V> 
- Overrides:
- getin class- AbstractMultiValuedMapDecorator<K,- V> 
- Parameters:
- key- the key to retrieve
- Returns:
- the Collectionof values, implementations should return an empty collection for no mapping
 
- 
keysDescription 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 interface- MultiValuedMap<K,- V> 
- Overrides:
- keysin class- AbstractMultiValuedMapDecorator<K,- V> 
- Returns:
- a multiset view of the keys contained in this map
 
- 
keySetDescription 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 interface- MultiValuedMap<K,- V> 
- Overrides:
- keySetin class- AbstractMultiValuedMapDecorator<K,- V> 
- Returns:
- a set view of the keys contained in this map
 
- 
mapIteratorDescription copied from interface:MultiValuedMapObtains 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.- Specified by:
- mapIteratorin interface- MultiValuedMap<K,- V> 
- Overrides:
- mapIteratorin class- AbstractMultiValuedMapDecorator<K,- V> 
- Returns:
- a map iterator
 
- 
putDescription copied from interface:MultiValuedMapAdds a key-value mapping to this multivalued map.Unlike a normal Mapthe previous value is not replaced. Instead, the new value is added to the collection stored against the key. Depending on the collection type used, duplicate key-value mappings may be allowed.The method will return trueif the size of the multivalued map has been increased because of this operation.- Specified by:
- putin interface- MultiValuedMap<K,- V> 
- Overrides:
- putin class- AbstractMultiValuedMapDecorator<K,- V> 
- Parameters:
- key- the key to store against
- 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
 
- 
putAllDescription copied from interface:MultiValuedMapAdds a mapping to the specified key for all values contained in the given Iterable.- Specified by:
- putAllin interface- MultiValuedMap<K,- V> 
- Overrides:
- putAllin class- AbstractMultiValuedMapDecorator<K,- V> 
- Parameters:
- key- the key to store against
- values- the values to add to the collection at the key, may not be null
- Returns:
- true if the map changed as a result of this operation
 
- 
putAllDescription copied from interface:MultiValuedMapCopies all mappings from the specified map to this multivalued map (optional operation).The effect of this call is equivalent to that of calling put(k, v)on this map once for each mapping from keykto valuevin the specified map.The behavior of this operation is undefined if the specified map is modified while the operation is in progress. - Specified by:
- putAllin interface- MultiValuedMap<K,- V> 
- Overrides:
- putAllin class- AbstractMultiValuedMapDecorator<K,- V> 
- Parameters:
- map- mappings to be stored in this map, may not be null
- Returns:
- true if the map changed as a result of this operation
 
- 
putAllDescription copied from interface:MultiValuedMapCopies all mappings from the specified map to this multivalued map (optional operation).The effect of this call is equivalent to that of calling put(k, v)on this map once for each mapping from keykto valuevin the specified map.The behavior of this operation is undefined if the specified map is modified while the operation is in progress. - Specified by:
- putAllin interface- MultiValuedMap<K,- V> 
- Overrides:
- putAllin class- AbstractMultiValuedMapDecorator<K,- V> 
- Parameters:
- map- mappings to be stored in this map, may not be null
- Returns:
- true if the map changed as a result of this operation
 
- 
removeDescription copied from interface:MultiValuedMapRemoves all values associated with the specified key.The returned collection may be modifiable, but updates will not be propagated to this multivalued map. In case no mapping was stored for the specified key, an empty, unmodifiable collection will be returned. - Specified by:
- removein interface- MultiValuedMap<K,- V> 
- Overrides:
- removein class- AbstractMultiValuedMapDecorator<K,- V> 
- Parameters:
- key- the key to remove values from
- Returns:
- the values that were removed
 
- 
removeMappingDescription copied from interface:MultiValuedMapRemoves a key-value mapping from the map.The item is removed from the collection mapped to the specified key. Other values attached to that key are unaffected. If the last value for a key is removed, implementations typically return an empty collection from a subsequent get(Object).- Specified by:
- removeMappingin interface- MultiValuedMap<K,- V> 
- Overrides:
- removeMappingin class- AbstractMultiValuedMapDecorator<K,- V> 
- Parameters:
- key- the key to remove from
- item- the item to remove
- Returns:
- true if the mapping was removed, false otherwise
 
- 
valuesDescription 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 interface- MultiValuedMap<K,- V> 
- Overrides:
- valuesin class- AbstractMultiValuedMapDecorator<K,- V> 
- Returns:
- a collection view of the values contained in this multivalued map
 
 
-