net.sf.molae.pipe.trafo
Class KeyTransformedMap<S,K,V>
java.lang.Object
java.util.AbstractMap<K,V>
net.sf.molae.pipe.basic.AbstractMapWithSet<K,V>
net.sf.molae.pipe.trafo.EntryTransformedMap<Map.Entry<S,V>,K,V>
net.sf.molae.pipe.trafo.KeyTransformedMap<S,K,V>
- All Implemented Interfaces:
- Map<K,V>
public final class KeyTransformedMap<S,K,V>
- extends EntryTransformedMap<Map.Entry<S,V>,K,V>
Provides a different view to an existing map by
transforming the key of every entry.
- Since:
- 1.1
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
KeyTransformedMap
public KeyTransformedMap(Map<S,V> base,
TwoWayTransformer<S,K> transformer)
- Constructs a KeyTransformedMap object.
- Parameters:
base
- the underlying maptransformer
- the transformer that maps each key to another one
- Throws:
NullPointerException
- if any of the specified objects is
null
.
newInstance
public static <S,K,V> KeyTransformedMap<S,K,V> newInstance(Map<S,V> base,
TwoWayTransformer<S,K> transformer)
- Constructs a KeyTransformedMap object.
- Parameters:
base
- the underlying maptransformer
- the transformer that maps each key to another one
- Throws:
NullPointerException
- if any of the specified objects is
null
.- Since:
- 2.0
containsKey
public boolean containsKey(Object key)
- Returns
true
if the base map contains a mapping with a
key that would transform into the specified key.
- Specified by:
containsKey
in interface Map<K,V>
- Overrides:
containsKey
in class AbstractMap<K,V>
- Parameters:
key
- key whose presence in this map is to be tested
- Returns:
true
if the base map contains a mapping with a
key that would transform into the specified element.
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interface Map<K,V>
- Overrides:
containsValue
in class AbstractMap<K,V>
get
public V get(Object key)
- Specified by:
get
in interface Map<K,V>
- Overrides:
get
in class AbstractMap<K,V>
put
public V put(K key,
V value)
- Specified by:
put
in interface Map<K,V>
- Overrides:
put
in class AbstractMap<K,V>
remove
public V remove(Object key)
- Specified by:
remove
in interface Map<K,V>
- Overrides:
remove
in class AbstractMap<K,V>
keySet
public Set<K> keySet()
- Description copied from class:
AbstractMapWithSet
- Returns a set view of the keys contained in this map.
This implementation returns a
typesafe
version of the key set
from AbstractMap
- Specified by:
keySet
in interface Map<K,V>
- Overrides:
keySet
in class AbstractMapWithSet<K,V>
- Returns:
- a set view of the keys contained in this map.
values
public Collection<V> values()
- Specified by:
values
in interface Map<K,V>
- Overrides:
values
in class AbstractMap<K,V>