public abstract class AbstractMostlySingleton<T> extends Object implements Set<T>
Does not support storing null
.
This class exists because it has multiple subclasses (currently MostlySingleton
and
IdentityMostlySingleton
).
Modifier and Type | Class and Description |
---|---|
static class |
AbstractMostlySingleton.State
The possible states of this set.
|
Modifier and Type | Field and Description |
---|---|
protected @Nullable Set<T> |
set
The wrapped set, non-null when the state is ANY.
|
protected AbstractMostlySingleton.State |
state
The current state.
|
protected T |
value
The current value, non-null when the state is SINGLETON.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractMostlySingleton(AbstractMostlySingleton.State s)
Create an AbstractMostlySingleton.
|
protected |
AbstractMostlySingleton(AbstractMostlySingleton.State s,
T v)
Create an AbstractMostlySingleton.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addAll(Collection<? extends T> c) |
void |
clear() |
boolean |
containsAll(Collection<?> c) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
boolean |
remove(@Nullable Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<S> S[] |
toArray(S[] a) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
parallelStream, removeIf, stream
protected AbstractMostlySingleton.State state
protected T value
protected AbstractMostlySingleton(AbstractMostlySingleton.State s)
protected AbstractMostlySingleton(AbstractMostlySingleton.State s, T v)
public int size()
public boolean isEmpty()
public boolean addAll(Collection<? extends T> c)
public Object[] toArray()
public <S> S[] toArray(S[] a)
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<T>
containsAll
in interface Set<T>
public boolean retainAll(Collection<?> c)
public boolean removeAll(Collection<?> c)