Top Description Constructors Methods
org.apache.commons.collections4.bidimap

public abstract Class AbstractBidiMapDecorator<K, V>

extends AbstractMapDecorator<K, V>
implements BidiMap<K, V>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.BidiMap, org.apache.commons.collections4.IterableMap, org.apache.commons.collections4.IterableGet, org.apache.commons.collections4.Get, org.apache.commons.collections4.Put, java.util.Map
Known Direct Subclasses
org.apache.commons.collections4.bidimap.AbstractOrderedBidiMapDecorator, org.apache.commons.collections4.bidimap.UnmodifiableBidiMap
Type Parameters
<K>
the type of the keys in this map
<V>
the type of the values in this map
Imports
java.util.Set, org.apache.commons.collections4.BidiMap, .MapIterator, org.apache.commons.collections4.map.AbstractMapDecorator

Provides a base decorator that enables additional functionality to be added to a BidiMap via decoration.

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.

Since
3.0

Constructor Summary

AccessConstructor and Description
protected
AbstractBidiMapDecorator(final BidiMap<K, V>
the map to decorate, must not be null
map
)

Constructor that wraps (not copies).

Method Summary

Modifier and TypeMethod and Description
protected BidiMap<K, V>

Returns:

the decorated map
decorated
()

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.decorated.

Gets the map being decorated.
public K
getKey(final Object
the value to find the key for
value
)

Implements org.apache.commons.collections4.BidiMap.getKey.

Gets the key that is currently mapped to the specified value.
public BidiMap<V, K>
inverseBidiMap()

Implements org.apache.commons.collections4.BidiMap.inverseBidiMap.

Gets a view of this map where the keys and values are reversed.
public MapIterator<K, V>
public K
removeValue(final Object
the value to find the key-value pair for
value
)

Implements org.apache.commons.collections4.BidiMap.removeValue.

Removes the key-value pair that is currently mapped to the specified value (optional operation).
public Set<V>
Inherited from org.apache.commons.collections4.map.AbstractMapDecorator:
clearcontainsKeycontainsValueentrySetequalsgethashCodeisEmptykeySetputputAllremovesizetoString

Constructor Detail

AbstractBidiMapDecoratorback to summary
protected AbstractBidiMapDecorator(final BidiMap<K, V> map)

Constructor that wraps (not copies).

Parameters
map:BidiMap<K, V>

the map to decorate, must not be null

Exceptions
NullPointerException:
if the collection is null

Method Detail

decoratedback to summary
protected BidiMap<K, V> decorated()

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.decorated.

Gets the map being decorated.

Returns:BidiMap<K, V>

the decorated map

Annotations
@Override
getKeyback to summary
public K getKey(final Object value)

Implements org.apache.commons.collections4.BidiMap.getKey.

Doc from org.apache.commons.collections4.BidiMap.getKey.

Gets the key that is currently mapped to the specified value.

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).

Parameters
value:Object

the value to find the key for

Returns:K

the mapped key, or null if not found

Annotations
@Override
inverseBidiMapback to summary
public BidiMap<V, K> inverseBidiMap()

Implements org.apache.commons.collections4.BidiMap.inverseBidiMap.

Doc from org.apache.commons.collections4.BidiMap.inverseBidiMap.

Gets 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.

Returns:BidiMap<V, K>

an inverted bidirectional map

Annotations
@Override
mapIteratorback to summary
public MapIterator<K, V> mapIterator()

Overrides org.apache.commons.collections4.map.AbstractIterableMap.mapIterator.

Implements org.apache.commons.collections4.IterableGet.mapIterator.

Doc from org.apache.commons.collections4.IterableGet.mapIterator.

Obtains a 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.

IterableMap<String,Integer> map = new HashedMap<String,Integer>();
MapIterator<String,Integer> it = map.mapIterator();
while (it.hasNext()) {
  String key = it.next();
  Integer value = it.getValue();
  it.setValue(value + 1);
}
Returns:MapIterator<K, V>

a map iterator

Annotations
@Override
removeValueback to summary
public K removeValue(final Object value)

Implements org.apache.commons.collections4.BidiMap.removeValue.

Doc from org.apache.commons.collections4.BidiMap.removeValue.

Removes the key-value pair that is currently mapped to the specified value (optional operation).

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).

Parameters
value:Object

the value to find the key-value pair for

Returns:K

the key that was removed, null if nothing removed

Annotations
@Override
valuesback to summary
public Set<V> values()

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.values.

Implements org.apache.commons.collections4.BidiMap.values, java.util.Map.values, org.apache.commons.collections4.Get.values.

Doc from org.apache.commons.collections4.BidiMap.values.

Returns a 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.

Returns:Set<V>

a set view of the values contained in this map

Annotations
@Override