public abstract class AbstractBidiMapDecorator<K,V> extends AbstractMapDecorator<K,V> implements BidiMap<K,V>
Methods are forwarded directly to the decorated map.
This implementation does not perform any special processing with the map views. Instead it simply returns the set/collection from the wrapped map. This may be undesirable, for example if you are trying to write a validating implementation it would provide a loophole around the validation. But, you might want that loophole, so this class is kept simple.
Modifier | Constructor and Description |
---|---|
protected |
AbstractBidiMapDecorator(BidiMap<K,V> map)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
protected BidiMap<K,V> |
decorated()
Gets the map being decorated.
|
K |
getKey(java.lang.Object value)
Gets the key that is currently mapped to the specified value.
|
BidiMap<V,K> |
inverseBidiMap()
Gets a view of this map where the keys and values are reversed.
|
MapIterator<K,V> |
mapIterator()
Obtains a
MapIterator over the map. |
K |
removeValue(java.lang.Object value)
Removes the key-value pair that is currently mapped to the specified
value (optional operation).
|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values
containsKey, containsValue, entrySet, get, isEmpty, keySet, remove, size, values
protected BidiMap<K,V> decorated()
decorated
in class AbstractMapDecorator<K,V>
public MapIterator<K,V> mapIterator()
AbstractIterableMap
MapIterator
over the map.
A map iterator is an efficient way of iterating over maps. There is no need to access the entry set or use Map Entry objects.
IterableMapmap = new HashedMap (); MapIterator it = map.mapIterator(); while (it.hasNext()) { String key = it.next(); Integer value = it.getValue(); it.setValue(value + 1); }
mapIterator
in interface IterableGet<K,V>
mapIterator
in class AbstractIterableMap<K,V>
public K getKey(java.lang.Object value)
BidiMap
If the value is not contained in the map, null
is returned.
Implementations should seek to make this method perform equally as well
as get(Object)
.
public K removeValue(java.lang.Object value)
BidiMap
If the value is not contained in the map, null
is returned.
Implementations should seek to make this method perform equally as well
as remove(Object)
.
removeValue
in interface BidiMap<K,V>
value
- the value to find the key-value pair fornull
if nothing removedpublic BidiMap<V,K> inverseBidiMap()
BidiMap
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.
inverseBidiMap
in interface BidiMap<K,V>
Copyright © 2001-2013. All Rights Reserved.