net.sf.molae.pipe.correct
Class TypeSafeCollection<E>

java.lang.Object
  extended by net.sf.molae.pipe.basic.ObjectProxy<B>
      extended by net.sf.molae.pipe.basic.CollectionProxy<Collection<E>,E>
          extended by net.sf.molae.pipe.correct.TypeSafeCollection<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>

public class TypeSafeCollection<E>
extends CollectionProxy<Collection<E>,E>

Wrapper class to receive the correct exceptions from collections. Some implementations of collections throw ClassCastException although not defined. This wrapper can be used to avoid this.


Constructor Summary
TypeSafeCollection(Collection<E> base)
          Constructs a new type safe collection wrapper.
 
Method Summary
 boolean contains(Object o)
          If the base implementation throws a ClassCastException, false is returned.
 boolean containsAll(Collection<?> c)
          If the base implementation throws a ClassCastException, false is returned.
 boolean remove(Object o)
          If the base implementation throws a ClassCastException, false is returned.
 
Methods inherited from class net.sf.molae.pipe.basic.CollectionProxy
add, addAll, clear, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from class net.sf.molae.pipe.basic.ObjectProxy
assertNotNull, equals, getBase, hashCode, toString, toVerboseString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

TypeSafeCollection

public TypeSafeCollection(Collection<E> base)
Constructs a new type safe collection wrapper.

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

contains

public boolean contains(Object o)
If the base implementation throws a ClassCastException, false is returned.

Specified by:
contains in interface Collection<E>
Overrides:
contains in class CollectionProxy<Collection<E>,E>

containsAll

public boolean containsAll(Collection<?> c)
If the base implementation throws a ClassCastException, false is returned.

Specified by:
containsAll in interface Collection<E>
Overrides:
containsAll in class CollectionProxy<Collection<E>,E>

remove

public boolean remove(Object o)
If the base implementation throws a ClassCastException, false is returned.

Specified by:
remove in interface Collection<E>
Overrides:
remove in class CollectionProxy<Collection<E>,E>