org.geotools.util
Class CheckedHashSet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended byjava.util.HashSet
              extended byjava.util.LinkedHashSet
                  extended byorg.geotools.util.CheckedHashSet
All Implemented Interfaces:
java.lang.Cloneable, org.opengis.util.Cloneable, java.util.Collection, java.io.Serializable, java.util.Set

public class CheckedHashSet
extends java.util.LinkedHashSet
implements org.opengis.util.Cloneable

Acts as a typed Set while we wait for Java 5.0.

Since:
2.1
Version:
$Id: CheckedHashSet.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Jody Garnett (Refractions Research), Martin Desruisseaux
See Also:
Serialized Form
To Do:
Provides synchronization facility on arbitrary lock, for use with the metadata package. The lock would be the metadata that owns this collection. Be carefull to update the lock after a clone (this work may be done in ).

Constructor Summary
CheckedHashSet(java.lang.Class type)
          Constructs a set of the specified type.
 
Method Summary
 boolean add(java.lang.Object element)
          Adds the specified element to this set if it is not already present.
protected  void ensureValidType(java.lang.Object element)
          Checks the type of the specified object.
 
Methods inherited from class java.util.HashSet
clear, clone, contains, isEmpty, iterator, remove, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.util.Cloneable
clone
 
Methods inherited from interface java.util.Set
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

CheckedHashSet

public CheckedHashSet(java.lang.Class type)
Constructs a set of the specified type.

Parameters:
type - The element type (should not be null).
Method Detail

ensureValidType

protected void ensureValidType(java.lang.Object element)
                        throws java.lang.IllegalArgumentException
Checks the type of the specified object. The default implementation ensure that the object is assignable to the type specified at construction time.

Parameters:
element - the object to check, or .
Throws:
java.lang.IllegalArgumentException - if the specified element is not of the expected type.

add

public boolean add(java.lang.Object element)
Adds the specified element to this set if it is not already present.

Specified by:
add in interface java.util.Set
Parameters:
element - element to be added to this set.
Returns:
if the set did not already contain the specified element.
Throws:
java.lang.IllegalArgumentException - if the specified element is not of the expected type.


Copyright © GeoTools. All Rights Reserved.