net.sf.molae.pipe.basic
Class AbstractMapWithSet<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by net.sf.molae.pipe.basic.AbstractMapWithSet<K,V>
All Implemented Interfaces:
Map<K,V>
Direct Known Subclasses:
EntryTransformedMap, KeyFilteredMap, ListAsMap, ListsBackedMap, MapTree

public abstract class AbstractMapWithSet<K,V>
extends AbstractMap<K,V>

Enhancement of AbstractMap that contains an AbstractSet to implement the entrySet. A map that is implemented by inheriting from AbstractMap has to implement entrySet(). AbstractMapWithSet provides a standard implementation for the entrySet based on AbstractSet.


Nested Class Summary
protected  class AbstractMapWithSet.EntrySet
          Provides a standard implementation of an entry set for a map.
 
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
AbstractMapWithSet()
           
 
Method Summary
 Set<Map.Entry<K,V>> entrySet()
          Returns a set view of the mappings contained in this map.
protected abstract  Iterator<Map.Entry<K,V>> getEntrySetIterator()
          Returns the iterator of the entry set.
 Set<K> keySet()
          Returns a set view of the keys contained in this map.
 int size()
          Returns the number of mappings in this map.
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, put, putAll, remove, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractMapWithSet

public AbstractMapWithSet()
Method Detail

getEntrySetIterator

protected abstract Iterator<Map.Entry<K,V>> getEntrySetIterator()
Returns the iterator of the entry set.

Returns:
the iterator of the entry set.

size

public int size()
Returns the number of mappings in this map. This implementation uses the iterator to count the elements.

Specified by:
size in interface Map<K,V>
Overrides:
size in class AbstractMap<K,V>
Returns:
the number of mappings in this map.

entrySet

public Set<Map.Entry<K,V>> entrySet()
Returns a set view of the mappings contained in this map. This implementation returns an instance of the inner class AbstractMapWithSet.EntrySet.

Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in class AbstractMap<K,V>
Returns:
a set view of the mappings contained in this map.

keySet

public Set<K> keySet()
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 AbstractMap<K,V>
Returns:
a set view of the keys contained in this map.