net.sf.molae.pipe.keyed
Class KeyedSetAsMap<K,V extends Keyed<K>>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by net.sf.molae.pipe.keyed.KeyedSetAsMap<K,V>
All Implemented Interfaces:
Map<K,V>

public final class KeyedSetAsMap<K,V extends Keyed<K>>
extends AbstractMap<K,V>

A set of Keyed objects represented as a map. The performance of this map is not good, so it should be used for transformtion only.


Nested Class Summary
 
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
KeyedSetAsMap(Collection<V> base)
          Creates a new map from the specified collection of keyed objects.
 
Method Summary
static
<K,V extends Keyed<K>>
Map.Entry<K,V>
asEntry(V base)
          Creates a map entry wrapper around a keyed object.
 void clear()
          Removes all mappings from the base set.
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,V>> entrySet()
           
 V put(K key, V value)
           
 int size()
           
 Collection<V> values()
           
 
Methods inherited from class java.util.AbstractMap
clone, containsKey, equals, get, hashCode, isEmpty, keySet, putAll, remove, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyedSetAsMap

public KeyedSetAsMap(Collection<V> base)
Creates a new map from the specified collection of keyed objects.

Parameters:
base - the underlying collection of keyed objects
Throws:
ClassCastException - if any element of the collection is not a Keyed object.
NullPointerException - if the specified collection is null.
Method Detail

asEntry

public static <K,V extends Keyed<K>> Map.Entry<K,V> asEntry(V base)
Creates a map entry wrapper around a keyed object.

Parameters:
base - underlying keyed object
Returns:
the new map entry

size

public int size()
Specified by:
size in interface Map<K,V extends Keyed<K>>
Overrides:
size in class AbstractMap<K,V extends Keyed<K>>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<K,V extends Keyed<K>>
Overrides:
containsValue in class AbstractMap<K,V extends Keyed<K>>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V extends Keyed<K>>
Overrides:
put in class AbstractMap<K,V extends Keyed<K>>
Throws:
ClassCastException - value is not a Keyed object or the base set does not allow the class of the specified object
IllegalArgumentException - The specified key is not the key of the specified value or the base set does not allow the specified value
NullPointerException - if value is null
UnsupportedOperationException - if the base set does not allow new values

clear

public void clear()
Removes all mappings from the base set.

Specified by:
clear in interface Map<K,V extends Keyed<K>>
Overrides:
clear in class AbstractMap<K,V extends Keyed<K>>
Throws:
UnsupportedOperationException - depending on the base set

values

public Collection<V> values()
Specified by:
values in interface Map<K,V extends Keyed<K>>
Overrides:
values in class AbstractMap<K,V extends Keyed<K>>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V extends Keyed<K>>
Specified by:
entrySet in class AbstractMap<K,V extends Keyed<K>>