E - data typepublic class ImmutableSet<E> extends Object implements Set<E>, Cloneable, Serializable
Set implementation that doesn't allow any data modifications to be done.
Unlike Collections.unmodifiableSet(Set) this implementation keeps set data copy.
If you need to provide an unmodifiable reference for your set use Collections implementation.| Constructor and Description |
|---|
ImmutableSet(Collection<? extends E> data)
Constructs new
ImmutableSet based on the specified Set. |
ImmutableSet(E... data)
Constructs new
ImmutableSet based on the specified list data. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E element) |
boolean |
addAll(Collection<? extends E> collection) |
void |
clear() |
boolean |
contains(Object element) |
boolean |
containsAll(Collection<?> collection) |
protected UnsupportedOperationException |
createModificationException()
Returns new
UnsupportedOperationException instance specific for this implementation. |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
remove(Object element) |
boolean |
removeAll(Collection<?> collection) |
boolean |
retainAll(Collection<?> collection) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] array) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitspliteratorparallelStream, removeIf, streampublic ImmutableSet(@NotNull E... data)
ImmutableSet based on the specified list data.data - Set datapublic ImmutableSet(@NotNull Collection<? extends E> data)
ImmutableSet based on the specified Set.data - Set datapublic int size()
public boolean isEmpty()
public boolean containsAll(@NotNull Collection<?> collection)
containsAll in interface Collection<E>containsAll in interface Set<E>public boolean addAll(@NotNull Collection<? extends E> collection)
public boolean removeAll(@NotNull Collection<?> collection)
public boolean retainAll(@NotNull Collection<?> collection)
public void clear()
@NotNull protected UnsupportedOperationException createModificationException()
UnsupportedOperationException instance specific for this implementation.UnsupportedOperationException instance specific for this implementationpublic int hashCode()
Copyright © 2020. All rights reserved.