net.sf.molae.pipe.trafo
Class ValueTransformedMap<K,S,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<K,S>,K,V>
              extended by net.sf.molae.pipe.trafo.ValueTransformedMap<K,S,V>
All Implemented Interfaces:
Map<K,V>

public final class ValueTransformedMap<K,S,V>
extends EntryTransformedMap<Map.Entry<K,S>,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
ValueTransformedMap(Map<K,S> base, TwoWayTransformer<S,V> transformer)
          Constructs a ValueTransformedMap object.
 
Method Summary
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 V get(Object key)
           
 Set<K> keySet()
          Returns a set view of the keys contained in this map.
static
<K,S,V> ValueTransformedMap<K,S,V>
newInstance(Map<K,S> base, TwoWayTransformer<S,V> transformer)
          Constructs a ValueTransformedMap 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

ValueTransformedMap

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

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

newInstance

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

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

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class AbstractMap<K,V>

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>