Class UnmodifiableBidiMap
- All Implemented Interfaces:
- Map,- BidiMap,- IterableMap,- Unmodifiable
BidiMap to ensure it can't be altered.- Since:
- Commons Collections 3.0
- Version:
- $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
- Author:
- Stephen Colebourne
- 
Nested Class Summary
- 
Field SummaryFields inherited from class org.apache.commons.collections.map.AbstractMapDecoratormap
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()static BidiMapFactory method to create an unmodifiable map.entrySet()Gets a view of this map where the keys and values are reversed.keySet()Obtains aMapIteratorover the map.Puts the key-value pair into the map, replacing any previous pair.voidremoveValue(Object value) Removes the key-value pair that is currently mapped to the specified value (optional operation).values()Methods inherited from class org.apache.commons.collections.bidimap.AbstractBidiMapDecoratorgetBidiMap, getKeyMethods inherited from class org.apache.commons.collections.map.AbstractMapDecoratorcontainsKey, containsValue, equals, get, getMap, hashCode, isEmpty, size, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAll, size
- 
Method Details- 
decorateFactory method to create an unmodifiable map.If the map passed in is already unmodifiable, it is returned. - Parameters:
- map- the map to decorate, must not be null
- Returns:
- an unmodifiable BidiMap
- Throws:
- IllegalArgumentException- if map is null
 
- 
clearpublic void clear()- Specified by:
- clearin interface- Map
- Overrides:
- clearin class- AbstractMapDecorator
 
- 
putDescription copied from interface:BidiMapPuts the key-value pair into the map, replacing any previous pair.When adding a key-value pair, the value may already exist in the map against a different key. That mapping is removed, to ensure that the value only occurs once in the inverse map. BidiMap map1 = new DualHashBidiMap(); map.put("A","B"); // contains A mapped to B, as per Map map.put("A","C"); // contains A mapped to C, as per Map BidiMap map2 = new DualHashBidiMap(); map.put("A","B"); // contains A mapped to B, as per Map map.put("C","B"); // contains C mapped to B, key A is removed
- 
putAll- Specified by:
- putAllin interface- Map
- Overrides:
- putAllin class- AbstractMapDecorator
 
- 
remove- Specified by:
- removein interface- Map
- Overrides:
- removein class- AbstractMapDecorator
 
- 
entrySet- Specified by:
- entrySetin interface- Map
- Overrides:
- entrySetin class- AbstractMapDecorator
 
- 
keySet- Specified by:
- keySetin interface- Map
- Overrides:
- keySetin class- AbstractMapDecorator
 
- 
values- Specified by:
- valuesin interface- Map
- Overrides:
- valuesin class- AbstractMapDecorator
 
- 
removeValueDescription copied from interface:BidiMapRemoves the key-value pair that is currently mapped to the specified value (optional operation).If the value is not contained in the map, nullis returned.Implementations should seek to make this method perform equally as well as remove(Object).- Specified by:
- removeValuein interface- BidiMap
- Overrides:
- removeValuein class- AbstractBidiMapDecorator
- Parameters:
- value- the value to find the key-value pair for
- Returns:
- the key that was removed, nullif nothing removed
 
- 
mapIteratorDescription copied from interface:BidiMapObtains aMapIteratorover the map.A map iterator is an efficient way of iterating over maps. It does not require that the map is stored using Map Entry objects which can increase performance. BidiMap map = new DualHashBidiMap(); MapIterator it = map.mapIterator(); while (it.hasNext()) { Object key = it.next(); Object value = it.getValue(); it.setValue("newValue"); }- Specified by:
- mapIteratorin interface- BidiMap
- Specified by:
- mapIteratorin interface- IterableMap
- Overrides:
- mapIteratorin class- AbstractBidiMapDecorator
- Returns:
- a map iterator
 
- 
inverseBidiMapDescription copied from interface:BidiMapGets a view of this map where the keys and values are reversed.Changes to one map will be visible in the other and vice versa. This enables both directions of the map to be accessed as a Map.Implementations should seek to avoid creating a new object every time this method is called. See AbstractMap.values()etc. Calling this method on the inverse map should return the original.- Specified by:
- inverseBidiMapin interface- BidiMap
- Overrides:
- inverseBidiMapin class- AbstractBidiMapDecorator
- Returns:
- an inverted bidirectional map
 
 
-