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>
,SequencedCollection<E>
,SequencedSet<E>
,Set<E>
,Immutable
public abstract sealed class SingletonSet<E>
extends Object
implements SequencedSet<E>, Immutable, Serializable
A
SequencedSet
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
final boolean
addAll
(Collection<? extends E> c) final void
clear()
final boolean
containsAll
(Collection<?> c) final boolean
final E
Deprecated, for removal: This API element is subject to removal in a future version.abstract E
getFirst()
final E
getLast()
abstract int
hashCode()
final boolean
isEmpty()
iterator()
static <E> @NonNull SingletonSet
<E> of
(@Nullable E element) final boolean
final boolean
removeAll
(Collection<?> c) final E
final E
final boolean
retainAll
(Collection<?> c) final SingletonSet
<E> reversed()
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
Methods inherited from interface java.util.SequencedCollection
addFirst, addLast
-
Constructor Details
-
SingletonSet
public SingletonSet()
-
-
Method Details
-
of
-
getElement
Deprecated, for removal: This API element is subject to removal in a future version.UsegetFirst()
instead.Return the single element contained in this set.- Returns:
- This set's element.
-
getFirst
- Specified by:
getFirst
in interfaceSequencedCollection<E>
-
getLast
- Specified by:
getLast
in interfaceSequencedCollection<E>
-
reversed
- Specified by:
reversed
in interfaceSequencedCollection<E>
- Specified by:
reversed
in interfaceSequencedSet<E>
-
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
-
removeFirst
- Specified by:
removeFirst
in interfaceSequencedCollection<E>
-
removeLast
- Specified by:
removeLast
in interfaceSequencedCollection<E>
-
clear
public final void clear() -
hashCode
public abstract int hashCode() -
equals
-
getFirst()
instead.