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
public class SetDecorator<E> extends Object implements Set<E>
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 ofSetwith 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.
-
-
Constructor Summary
Constructors Constructor Description SetDecorator(Set<E> set)Constructs a new set decorator, wrapping the specified set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E e)Adds the specified element to the set if it is not already present (optional operation).booleanaddAll(Collection<? extends E> c)Adds all of the elements in the specified collection to the set if they're not already present (optional operation).voidclear()Removes all of the elements from the set (optional operation).booleancontains(Object o)Returnstrueif the set contains the specified element.booleancontainsAll(Collection<?> c)Returnstrueif the set contains all of the elements of the specified collection.booleanequals(Object o)Compares the specified object with the set for equality.inthashCode()booleanisEmpty()Iterator<E>iterator()booleanremove(Object o)Removes the specified element from the set if it is present (optional operation).booleanremoveAll(Collection<?> c)Removes from the set all of its elements that are contained in the specified collection (optional operation).booleanretainAll(Collection<?> c)Retains only the elements in the set that are contained in the specified collection (optional operation).intsize()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
-
-
-
-
Method Detail
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
Returnstrueif the set contains the specified element.- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Parameters:
o- element whose presence in the set is to be tested.- Returns:
trueif 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 isnulland the set does not permit null elements (optional).
-
toArray
public Object[] 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:
toArrayin interfaceCollection<E>- Specified by:
toArrayin 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
public boolean add(E e)
Adds the specified element to the set if it is not already present (optional operation).- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Parameters:
e- element to be added to the set.- Returns:
trueif the set did not already contain the specified element.- Throws:
UnsupportedOperationException- if theaddoperation 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 isnulland the set does not permit null elements.IllegalArgumentException- if some property of the specified element prevents it from being added to the set.
-
remove
public boolean remove(Object o)
Removes the specified element from the set if it is present (optional operation).- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Parameters:
o- object to be removed from the set, if present.- Returns:
trueif 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 isnulland the set does not permit null elements (optional).UnsupportedOperationException- if theremoveoperation is not supported by the set.
-
containsAll
public boolean containsAll(Collection<?> c)
Returnstrueif the set contains all of the elements of the specified collection.- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>- Parameters:
c- collection to be checked for containment in the set.- Returns:
trueif 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 morenullelements and the set does not permit null elements (optional), or if the specified collection isnull.
-
addAll
public 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).- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceSet<E>- Parameters:
c- collection containing elements to be added to the set.- Returns:
trueif the set changed as a result of the call.- Throws:
UnsupportedOperationException- if theaddAlloperation 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 morenullelements 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
public boolean retainAll(Collection<?> c)
Retains only the elements in the set that are contained in the specified collection (optional operation).- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceSet<E>- Parameters:
c- collection containing elements to be retained in the set.- Returns:
trueif 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 anullelement and the specified collection does not permit null elements (optional), or if the specified collection isnull.
-
removeAll
public boolean removeAll(Collection<?> c)
Removes from the set all of its elements that are contained in the specified collection (optional operation).- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceSet<E>- Parameters:
c- collection containing elements to be removed from the set.- Returns:
trueif the set changed as a result of the call.- Throws:
UnsupportedOperationException- if theremoveAlloperation 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 anullelement 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:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Throws:
UnsupportedOperationException- if theclearmethod is not supported by the set.
-
equals
public boolean equals(Object o)
Compares the specified object with the set for equality.
-
-