@GwtCompatible(serializable=true, emulated=true) final class SingletonImmutableList<E> extends ImmutableList<E>
ImmutableList
with exactly one element.ImmutableList.Builder<E>, ImmutableList.SerializedForm, ImmutableList.SubList
ImmutableCollection.ArrayBasedBuilder<E>
Constructor and Description |
---|
SingletonImmutableList(E element) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.lang.Object object) |
(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.
|
boolean |
equals(java.lang.Object object) |
E |
get(int index) |
int |
hashCode() |
int |
indexOf(java.lang.Object object) |
boolean |
isEmpty() |
(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 |
lastIndexOf(java.lang.Object object) |
ImmutableList<E> |
reverse()
Returns a view of this immutable list in reverse order.
|
int |
size() |
ImmutableList<E> |
subList(int fromIndex,
int toIndex)
Returns an immutable list of the elements between the specified
fromIndex , inclusive, and toIndex , exclusive. |
java.lang.String |
toString() |
add, addAll, asImmutableList, asImmutableList, asList, builder, copyOf, copyOf, copyOf, copyOf, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, of, remove, set, subListUnchecked, writeReplace
add, addAll, clear, createAsList, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
final transient E element
SingletonImmutableList(E element)
public E get(int index)
public int indexOf(@Nullable java.lang.Object object)
indexOf
in interface java.util.List<E>
indexOf
in class ImmutableList<E>
public UnmodifiableIterator<E> iterator()
ImmutableCollection
public int lastIndexOf(@Nullable java.lang.Object object)
lastIndexOf
in interface java.util.List<E>
lastIndexOf
in class ImmutableList<E>
public int size()
public ImmutableList<E> subList(int fromIndex, int toIndex)
ImmutableList
fromIndex
, inclusive, and toIndex
, exclusive. (If fromIndex
and toIndex
are equal, the empty immutable list is
returned.)subList
in interface java.util.List<E>
subList
in class ImmutableList<E>
public ImmutableList<E> reverse()
ImmutableList
ImmutableList.of(1, 2, 3).reverse()
is equivalent to ImmutableList.of(3, 2, 1)
.reverse
in class ImmutableList<E>
public boolean contains(@Nullable java.lang.Object object)
contains
in interface java.util.Collection<E>
contains
in interface java.util.List<E>
contains
in class ImmutableList<E>
public boolean equals(@Nullable java.lang.Object object)
equals
in interface java.util.Collection<E>
equals
in interface java.util.List<E>
equals
in class ImmutableList<E>
public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in interface java.util.List<E>
hashCode
in class ImmutableList<E>
public java.lang.String toString()
toString
in class java.util.AbstractCollection<E>
public boolean isEmpty()
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 ImmutableList<E>