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(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(Object value)
Removes the key-value pair that is currently mapped to the specified
value (optional operation).
|
Set<V> |
values()
Returns a
Set view of the values contained in this map. |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size
containsKey, containsValue, entrySet, get, isEmpty, keySet, remove, size
protected AbstractBidiMapDecorator(BidiMap<K,V> map)
map
- the map to decorate, must not be nullIllegalArgumentException
- if the collection is nullprotected 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(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(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>
public Set<V> values()
BidiMap
Set
view of the values contained in this 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
remove operation), the results of the iteration are undefined.
The set supports element removal, which removes the corresponding
mapping from the map, via the Iterator.remove,
Collection.remove, removeAll,
retainAll and clear operations. It does not
support the add or addAll operations.Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.