net.sf.molae.pipe.genimpl
Class KeyProjection<E>

java.lang.Object
  extended by net.sf.molae.pipe.basic.ObjectProxy<B>
      extended by net.sf.molae.pipe.basic.CollectionProxy<B,E>
          extended by net.sf.molae.pipe.basic.SetProxy<Set<E>,E>
              extended by net.sf.molae.pipe.genimpl.KeyProjection<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
Direct Known Subclasses:
SortedKeyProjection

public class KeyProjection<E>
extends SetProxy<Set<E>,E>

Implements a set on an arbitrary map by mapping each set element to a map entry with the set element as key and a dummy element as value of the map.


Constructor Summary
KeyProjection(Map<E,Object> base)
          Constructs a new key projection of the specified map.
 
Method Summary
 boolean add(E o)
           
 boolean addAll(Collection<? extends E> c)
           
 void clear()
          Removes all of the elements from the base map.
 boolean contains(Object o)
           
 boolean isEmpty()
           
 boolean remove(Object o)
          Removes the mapping with the specified object as key from the base map.
 int size()
           
 
Methods inherited from class net.sf.molae.pipe.basic.SetProxy
equals
 
Methods inherited from class net.sf.molae.pipe.basic.CollectionProxy
containsAll, iterator, removeAll, retainAll, toArray, toArray
 
Methods inherited from class net.sf.molae.pipe.basic.ObjectProxy
assertNotNull, getBase, hashCode, toString, toVerboseString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, hashCode, iterator, removeAll, retainAll, toArray, toArray
 

Constructor Detail

KeyProjection

public KeyProjection(Map<E,Object> base)
Constructs a new key projection of the specified map.

Parameters:
base - The base map of this set. The map may contain entries, but must not contain null values.
Throws:
NullPointerException - if the specified object is null.
Method Detail

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>
Overrides:
size in class CollectionProxy<Set<E>,E>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface Set<E>
Overrides:
isEmpty in class CollectionProxy<Set<E>,E>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Set<E>
Overrides:
contains in class CollectionProxy<Set<E>,E>

add

public boolean add(E o)
Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>
Overrides:
add in class CollectionProxy<Set<E>,E>

addAll

public boolean addAll(Collection<? extends E> c)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>
Overrides:
addAll in class CollectionProxy<Set<E>,E>

remove

public boolean remove(Object o)
Removes the mapping with the specified object as key from the base map.

Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>
Overrides:
remove in class CollectionProxy<Set<E>,E>
Throws:
UnsupportedOperationException - depending on the base map

clear

public void clear()
Removes all of the elements from the base map.

Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Overrides:
clear in class CollectionProxy<Set<E>,E>
Throws:
UnsupportedOperationException - depending on the base map