Package org.apache.sis.internal.util
Class CheckedHashSet<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
java.util.HashSet<E>
java.util.LinkedHashSet<E>
org.apache.sis.internal.util.CheckedHashSet<E>
- Type Parameters:
E- the type of elements in the set.
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<E>,Collection<E>,Set<E>,CheckedContainer<E>
A checked
LinkedHashSet.
The type checks are performed at run-time in addition to the compile-time checks.
Using this class is similar to wrapping a LinkedHashSet using the methods provided
in the standard Collections class, except for the following differences:
- Avoid one level of indirection.
- Does not accept null elements.
- Since:
- 0.3
- Version:
- 0.4
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longSerial version UID for compatibility with different versions.The element type. -
Constructor Summary
ConstructorsConstructorDescriptionCheckedHashSet(Class<E> type) Constructs a set of the specified type.CheckedHashSet(Class<E> type, int capacity) Constructs a set of the specified type and initial capacity. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the specified element to this set if it is not already present.Returns the element type given at construction time.Methods inherited from class java.util.LinkedHashSet
spliteratorMethods inherited from class java.util.HashSet
clear, clone, contains, isEmpty, iterator, remove, sizeMethods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial version UID for compatibility with different versions.- See Also:
-
type
The element type.
-
-
Constructor Details
-
CheckedHashSet
Constructs a set of the specified type.- Parameters:
type- the element type (cannot be null).
-
CheckedHashSet
Constructs a set of the specified type and initial capacity.- Parameters:
type- the element type (should not be null).capacity- the initial capacity.
-
-
Method Details
-
getElementType
Returns the element type given at construction time.- Specified by:
getElementTypein interfaceCheckedContainer<E>- Returns:
- the element type.
-
add
Adds the specified element to this set if it is not already present.- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classHashSet<E>- Parameters:
element- element to be added to this set.- Returns:
trueif the set did not already contain the specified element.- Throws:
IllegalArgumentException- if the specified element is not of the expected type.
-