E - The type of the set decorator.public class SetDecorator<E> extends Object implements Set<E>
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.| Modifier and Type | Field and Description |
|---|---|
protected Set<E> |
set
The set wrapped by this decorator.
|
| Constructor and Description |
|---|
SetDecorator(Set<E> set)
Constructs a new set decorator, wrapping the specified set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e)
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 |
contains(Object o)
Returns
true if the set contains the specified element. |
boolean |
containsAll(Collection<?> c)
Returns
true if the set contains all of the elements of the specified
collection. |
boolean |
equals(Object o)
Compares the specified object with the set for equality.
|
int |
hashCode() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
remove(Object o)
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.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitspliteratorparallelStream, removeIf, streampublic int size()
public boolean isEmpty()
public boolean contains(Object o)
true if the set contains the specified element.contains in interface Collection<E>contains in interface Set<E>o - element whose presence in the set is to be tested.true if the set contains the specified element.ClassCastException - if the type of the specified element is incompatible with the set (optional).NullPointerException - if the specified element is null and the set does not permit null
elements (optional).public Object[] toArray()
public <T> T[] toArray(T[] a)
toArray in interface Collection<E>toArray in interface Set<E>T - runtime type of the arraya - 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.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 is null.public boolean add(E e)
add in interface Collection<E>add in interface Set<E>e - element to be added to the set.true if the set did not already contain the specified element.UnsupportedOperationException - if the add 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 is null and the set does not permit null elements.IllegalArgumentException - if some property of the specified element prevents it from being added to
the set.public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>o - object to be removed from the set, if present.true if the set contained the specified element.ClassCastException - if the type of the specified element is incompatible with the set (optional).NullPointerException - if the specified element is null and the set does not permit null
elements (optional).UnsupportedOperationException - if the remove operation is not supported by the set.public boolean containsAll(Collection<?> c)
true if the set contains all of the elements of the specified
collection.containsAll in interface Collection<E>containsAll in interface Set<E>c - collection to be checked for containment in the set.true if the set contains all of the elements of the specified collection.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 more null elements and the
set does not permit null elements (optional), or if the specified collection is null.public boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>addAll in interface Set<E>c - collection containing elements to be added to the set.true if the set changed as a result of the call.UnsupportedOperationException - if the addAll 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 more null elements and the
set does not permit null elements, or if the specified collection is null.IllegalArgumentException - if some property of an element of the specified collection prevents it from
being added to the set.public boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>retainAll in interface Set<E>c - collection containing elements to be retained in the set.true if the set changed as a result of the call.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 a null element and the specified collection does
not permit null elements (optional), or if the specified collection is null.public boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>removeAll in interface Set<E>c - collection containing elements to be removed from the set.true if the set changed as a result of the call.UnsupportedOperationException - if the removeAll 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 a null element and the specified collection does
not permit null elements (optional), or if the specified collection is null.public void clear()
clear in interface Collection<E>clear in interface Set<E>UnsupportedOperationException - if the clear method is not supported by the set.public boolean equals(Object o)
Copyright © 2025 Open Identity Platform Community. All rights reserved.