Package org.opendaylight.yangtools.util
Class SingletonSet<E>
- java.lang.Object
-
- org.opendaylight.yangtools.util.SingletonSet<E>
-
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,Set<E>
,Immutable
,MutationBehaviour<Immutable>
@Beta public abstract class SingletonSet<E> extends Object implements Set<E>, Immutable, Serializable
ASet
containing a single value. For some reason neither Java nor Guava provide direct access to the retained element -- which is desirable in some situations, as is the case inSharedSingletonMap.entrySet()
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SingletonSet()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
add(E e)
boolean
addAll(Collection<? extends E> c)
void
clear()
boolean
containsAll(Collection<?> c)
boolean
equals(Object obj)
abstract @Nullable E
getElement()
abstract int
hashCode()
boolean
isEmpty()
@NonNull Iterator<E>
iterator()
static <E> @NonNull SingletonSet<E>
of(@Nullable E element)
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
boolean
retainAll(Collection<?> c)
int
size()
abstract @NonNull Spliterator<E>
spliterator()
@NonNull Object[]
toArray()
<T> @NonNull T[]
toArray(T[] a)
-
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
-
-
-
-
Method Detail
-
of
public static <E> @NonNull SingletonSet<E> of(@Nullable E element)
-
getElement
public abstract @Nullable E getElement()
-
size
public final int size()
-
isEmpty
public final boolean isEmpty()
-
spliterator
public abstract @NonNull Spliterator<E> spliterator()
- Specified by:
spliterator
in interfaceCollection<E>
- Specified by:
spliterator
in interfaceIterable<E>
- Specified by:
spliterator
in interfaceSet<E>
-
toArray
public final @NonNull Object[] toArray()
-
toArray
public final <T> @NonNull T[] toArray(T[] a)
-
add
public final boolean add(E e)
-
remove
public final boolean remove(Object o)
-
containsAll
public final boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
-
addAll
public final boolean addAll(Collection<? extends E> c)
-
retainAll
public final boolean retainAll(Collection<?> c)
-
removeAll
public final boolean removeAll(Collection<?> c)
-
clear
public final void clear()
-
hashCode
public abstract int hashCode()
-
-