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
public abstract sealed class SingletonSet<E>
extends Object
implements Set<E>, Immutable, Serializable
A
Set
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 in SharedSingletonMap.entrySet()
.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
final boolean
addAll
(Collection<? extends E> c) final void
clear()
final boolean
containsAll
(Collection<?> c) final boolean
abstract E
Return the single element contained in this set.abstract int
hashCode()
final boolean
isEmpty()
iterator()
static <E> @NonNull SingletonSet<E>
of
(@Nullable E element) final boolean
final boolean
removeAll
(Collection<?> c) final boolean
retainAll
(Collection<?> c) final int
size()
abstract @NonNull Spliterator<E>
final @NonNull Object[]
toArray()
final <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
-
Constructor Details
-
SingletonSet
public SingletonSet()
-
-
Method Details
-
of
-
getElement
Return the single element contained in this set.- Returns:
- This set's element.
-
size
public final int size() -
isEmpty
public final boolean isEmpty() -
iterator
-
spliterator
- Specified by:
spliterator
in interfaceCollection<E>
- Specified by:
spliterator
in interfaceIterable<E>
- Specified by:
spliterator
in interfaceSet<E>
-
toArray
-
toArray
public final <T> @NonNull T[] toArray(T[] a) -
add
-
remove
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
-
addAll
-
retainAll
-
removeAll
-
clear
public final void clear() -
hashCode
public abstract int hashCode() -
equals
-