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>
,SequencedCollection<E>
,SequencedSet<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 long
Serial 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 TypeMethodDescriptionboolean
Adds 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
addFirst, addLast, getFirst, getLast, newLinkedHashSet, removeFirst, removeLast, reversed, spliterator
Methods inherited from class java.util.HashSet
clear, clone, contains, isEmpty, iterator, newHashSet, remove, size, toArray, toArray
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
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:
getElementType
in interfaceCheckedContainer<E>
- Returns:
- the element type.
-
add
Adds the specified element to this set if it is not already present.- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classHashSet<E>
- Parameters:
element
- element to be added to this set.- Returns:
true
if the set did not already contain the specified element.- Throws:
IllegalArgumentException
- if the specified element is not of the expected type.
-