net.sf.molae.pipe.trafo
Class KeyTransformedMap<S,K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by net.sf.molae.pipe.basic.AbstractMapWithSet<K,V>
          extended by net.sf.molae.pipe.trafo.EntryTransformedMap<Map.Entry<S,V>,K,V>
              extended by 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 Class Summary
 
Nested classes/interfaces inherited from class net.sf.molae.pipe.basic.AbstractMapWithSet
AbstractMapWithSet.EntrySet
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
KeyTransformedMap(Map<S,V> base, TwoWayTransformer<S,K> transformer)
          Constructs a KeyTransformedMap object.
 
Method Summary
 boolean containsKey(Object key)
          Returns true if the base map contains a mapping with a key that would transform into the specified key.
 boolean containsValue(Object value)
           
 V get(Object key)
           
 Set<K> keySet()
          Returns a set view of the keys contained in this map.
static
<S,K,V> KeyTransformedMap<S,K,V>
newInstance(Map<S,V> base, TwoWayTransformer<S,K> transformer)
          Constructs a KeyTransformedMap object.
 V put(K key, V value)
           
 V remove(Object key)
           
 Collection<V> values()
           
 
Methods inherited from class net.sf.molae.pipe.trafo.EntryTransformedMap
clear, getEntrySetIterator, getTransformer, size
 
Methods inherited from class net.sf.molae.pipe.basic.AbstractMapWithSet
entrySet
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, putAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyTransformedMap

public KeyTransformedMap(Map<S,V> base,
                         TwoWayTransformer<S,K> transformer)
Constructs a KeyTransformedMap object.

Parameters:
base - the underlying map
transformer - the transformer that maps each key to another one
Throws:
NullPointerException - if any of the specified objects is null.
Method Detail

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 map
transformer - 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>