Package org.forgerock.http.util
Class SetDecorator<E>
java.lang.Object
org.forgerock.http.util.SetDecorator<E>
- Type Parameters:
E
- The type of the set decorator.
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
- Direct Known Subclasses:
CaseInsensitiveSet
,DirtySet
Contains another set, which is uses as its basic source of data, possibly transforming the
data along the way. This class itself simply overrides all methods of
Set
with
versions that pass all requests to the contained set. Subclasses may further override
some of these methods and may also provide additional methods and fields.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSetDecorator
(Set<E> set) Constructs a new set decorator, wrapping the specified set. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds the specified element to the set if it is not already present (optional operation).boolean
addAll
(Collection<? extends E> c) Adds all of the elements in the specified collection to the set if they're not already present (optional operation).void
clear()
Removes all of the elements from the set (optional operation).boolean
Returnstrue
if the set contains the specified element.boolean
containsAll
(Collection<?> c) Returnstrue
if the set contains all of the elements of the specified collection.boolean
Compares the specified object with the set for equality.int
hashCode()
boolean
isEmpty()
iterator()
boolean
Removes the specified element from the set if it is present (optional operation).boolean
removeAll
(Collection<?> c) Removes from the set all of its elements that are contained in the specified collection (optional operation).boolean
retainAll
(Collection<?> c) Retains only the elements in the set that are contained in the specified collection (optional operation).int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Returns an array containing all of the elements in the set; the runtime type of the returned array is that of the specified array.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
spliterator
-
Field Details
-
set
The set wrapped by this decorator.
-
-
Constructor Details
-
SetDecorator
Constructs a new set decorator, wrapping the specified set.- Parameters:
set
- the set to wrap with the decorator.
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
Returnstrue
if the set contains the specified element.- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Parameters:
o
- element whose presence in the set is to be tested.- Returns:
true
if the set contains the specified element.- Throws:
ClassCastException
- if the type of the specified element is incompatible with the set (optional).NullPointerException
- if the specified element isnull
and the set does not permit null elements (optional).
-
iterator
-
toArray
-
toArray
public <T> T[] toArray(T[] a) Returns an array containing all of the elements in the set; the runtime type of the returned array is that of the specified array.- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Type Parameters:
T
- runtime type of the array- Parameters:
a
- the array into which the elements of the set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.- Returns:
- an array containing all the elements in the set.
- Throws:
ArrayStoreException
- if the runtime type of the specified array is not a supertype of the runtime type of every element in the set.NullPointerException
- if the specified array isnull
.
-
add
Adds the specified element to the set if it is not already present (optional operation).- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Parameters:
e
- element to be added to the set.- Returns:
true
if the set did not already contain the specified element.- Throws:
UnsupportedOperationException
- if theadd
operation is not supported by the set.ClassCastException
- if the class of the specified element prevents it from being added to the set.NullPointerException
- if the specified element isnull
and the set does not permit null elements.IllegalArgumentException
- if some property of the specified element prevents it from being added to the set.
-
remove
Removes the specified element from the set if it is present (optional operation).- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Parameters:
o
- object to be removed from the set, if present.- Returns:
true
if the set contained the specified element.- Throws:
ClassCastException
- if the type of the specified element is incompatible with the set (optional).NullPointerException
- if the specified element isnull
and the set does not permit null elements (optional).UnsupportedOperationException
- if theremove
operation is not supported by the set.
-
containsAll
Returnstrue
if the set contains all of the elements of the specified collection.- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
- Parameters:
c
- collection to be checked for containment in the set.- Returns:
true
if the set contains all of the elements of the specified collection.- Throws:
ClassCastException
- if the types of one or more elements in the specified collection are incompatible with the set (optional).NullPointerException
- if the specified collection contains one or morenull
elements and the set does not permit null elements (optional), or if the specified collection isnull
.
-
addAll
Adds all of the elements in the specified collection to the set if they're not already present (optional operation).- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceSet<E>
- Parameters:
c
- collection containing elements to be added to the set.- Returns:
true
if the set changed as a result of the call.- Throws:
UnsupportedOperationException
- if theaddAll
operation is not supported by the set.ClassCastException
- if the class of an element of the specified collection prevents it from being added to the set.NullPointerException
- if the specified collection contains one or morenull
elements and the set does not permit null elements, or if the specified collection isnull
.IllegalArgumentException
- if some property of an element of the specified collection prevents it from being added to the set.
-
retainAll
Retains only the elements in the set that are contained in the specified collection (optional operation).- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceSet<E>
- Parameters:
c
- collection containing elements to be retained in the set.- Returns:
true
if the set changed as a result of the call.- Throws:
UnsupportedOperationException
- if the retainAll operation is not supported by the set.ClassCastException
- if the class of an element of the set is incompatible with the specified collection (optional).NullPointerException
- if the set contains anull
element and the specified collection does not permit null elements (optional), or if the specified collection isnull
.
-
removeAll
Removes from the set all of its elements that are contained in the specified collection (optional operation).- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceSet<E>
- Parameters:
c
- collection containing elements to be removed from the set.- Returns:
true
if the set changed as a result of the call.- Throws:
UnsupportedOperationException
- if theremoveAll
operation is not supported by the set.ClassCastException
- if the class of an element of the set is incompatible with the specified collection (optional).NullPointerException
- if the set contains anull
element and the specified collection does not permit null elements (optional), or if the specified collection isnull
.
-
clear
public void clear()Removes all of the elements from the set (optional operation).- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Throws:
UnsupportedOperationException
- if theclear
method is not supported by the set.
-
equals
Compares the specified object with the set for equality. -
hashCode
public int hashCode()
-