net.sf.molae.pipe.correct
Class TypeSafeMap<K,V>

java.lang.Object
  extended by net.sf.molae.pipe.basic.ObjectProxy<B>
      extended by net.sf.molae.pipe.basic.MapProxy<Map<K,V>,K,V>
          extended by net.sf.molae.pipe.correct.TypeSafeMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class TypeSafeMap<K,V>
extends MapProxy<Map<K,V>,K,V>

Wrapper class to receive the correct exceptions from maps.

Written as a wrapper for TreeMap: Its keySet throws a ClassCastException in contains().

See Also:
TypeSafeCollection

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
TypeSafeMap(Map<K,V> base)
          Constructs a new type safe map wrapper.
 
Method Summary
 Set<Map.Entry<K,V>> entrySet()
          Returns a TypeSafeCollection version of the entrySet().
 Set<K> keySet()
          Returns a TypeSafeCollection version of the keySet().
 V remove(Object key)
          If the base implementation throws a ClassCastException, null is returned.
 
Methods inherited from class net.sf.molae.pipe.basic.MapProxy
clear, containsKey, containsValue, equals, get, isEmpty, put, putAll, size, values
 
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.Map
hashCode
 

Constructor Detail

TypeSafeMap

public TypeSafeMap(Map<K,V> base)
Constructs a new type safe map wrapper.

Parameters:
base - the underlying map
Throws:
NullPointerException - if the specified object is null.
Method Detail

remove

public V remove(Object key)
If the base implementation throws a ClassCastException, null is returned.

Specified by:
remove in interface Map<K,V>
Overrides:
remove in class MapProxy<Map<K,V>,K,V>
Throws:
UnsupportedOperationException - depending on the base map

keySet

public Set<K> keySet()
Returns a TypeSafeCollection version of the keySet().

Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class MapProxy<Map<K,V>,K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Returns a TypeSafeCollection version of the entrySet().

Specified by:
entrySet in interface Map<K,V>
Overrides:
entrySet in class MapProxy<Map<K,V>,K,V>