final class SingletonImmutableSet<E> extends ImmutableSet<E>
ImmutableSet
with exactly one element.ImmutableSet.Builder<E>, ImmutableSet.CachingAsList<E>, ImmutableSet.Indexed<E>
Modifier and Type | Field and Description |
---|---|
(package private) E |
element |
MAX_TABLE_SIZE, SPLITERATOR_CHARACTERISTICS
Constructor and Description |
---|
SingletonImmutableSet(E element) |
Modifier and Type | Method and Description |
---|---|
ImmutableList<E> |
asList()
Returns an
ImmutableList containing the same elements, in the same order, as this
collection. |
boolean |
contains(java.lang.Object target) |
(package private) int |
copyIntoArray(java.lang.Object[] dst,
int offset)
Copies the contents of this immutable collection into the specified array at the specified
offset.
|
int |
hashCode() |
(package private) boolean |
isPartialView()
Returns
true if this immutable collection's implementation contains references to
user-created objects that aren't accessible via this collection's methods. |
UnmodifiableIterator<E> |
iterator()
Returns an unmodifiable iterator across the elements in this collection.
|
int |
size() |
java.lang.String |
toString() |
builder, builderWithExpectedSize, chooseTableSize, copyOf, copyOf, copyOf, copyOf, equals, isHashCodeFast, of, of, of, of, of, of, of, toImmutableSet, writeReplace
add, addAll, clear, internalArray, internalArrayEnd, internalArrayStart, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
final transient E element
SingletonImmutableSet(E element)
public int size()
public boolean contains(@CheckForNull java.lang.Object target)
contains
in interface java.util.Collection<E>
contains
in interface java.util.Set<E>
contains
in class ImmutableCollection<E>
public UnmodifiableIterator<E> iterator()
ImmutableCollection
public ImmutableList<E> asList()
ImmutableCollection
ImmutableList
containing the same elements, in the same order, as this
collection.
Performance note: in most cases this method can return quickly without actually copying anything. The exact circumstances under which the copy is performed are undefined and subject to change.
asList
in class ImmutableCollection<E>
boolean isPartialView()
ImmutableCollection
true
if this immutable collection's implementation contains references to
user-created objects that aren't accessible via this collection's methods. This is generally
used to determine whether copyOf
implementations should make an explicit copy to avoid
memory leaks.isPartialView
in class ImmutableCollection<E>
int copyIntoArray(java.lang.Object[] dst, int offset)
ImmutableCollection
offset + size()
.copyIntoArray
in class ImmutableCollection<E>
public final int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in interface java.util.Set<E>
hashCode
in class ImmutableSet<E>
public java.lang.String toString()
toString
in class java.util.AbstractCollection<E>