Top Description Fields Constructors Methods
com.google.common.collect

pack-priv final Class SingletonImmutableList<E>

extends ImmutableList<E>
Class Inheritance
Annotations
@GwtCompatible
serializable:true
emulated:true
@SuppressWarnings:serial
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

Implementation of ImmutableList with exactly one element.
Author
Hayward Chan

Field Summary

Modifier and TypeField and Description
pack-priv final transient E

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public E
get(int
index of the element to return
index
)

Implements java.util.List.get.

Returns the element at the specified position in this list.
pack-priv boolean
isPartialView()

Implements abstract com.google.common.collect.ImmutableCollection.isPartialView.

Returns true if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods.
public UnmodifiableIterator<E>
iterator()

Overrides com.google.common.collect.ImmutableList.iterator.

Implements java.util.List.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this list in proper sequence.
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.
public Spliterator<E>
public ImmutableList<E>
subList(int
low endpoint (inclusive) of the subList
fromIndex
,
int
high endpoint (exclusive) of the subList
toIndex
)

Overrides com.google.common.collect.ImmutableList.subList.

Implements java.util.List.subList.

Returns an immutable list of the elements between the specified fromIndex, inclusive, and toIndex, exclusive.
public String
toString()

Overrides java.util.AbstractCollection.toString.

Returns a string representation of this collection.
pack-priv Object
Inherited from com.google.common.collect.ImmutableList:
addaddAllasImmutableListasImmutableListasListbuilderbuilderWithExpectedSizecontainscopyIntoArraycopyOfcopyOfcopyOfcopyOfequalsforEachhashCodeindexOflastIndexOflistIteratorlistIteratorofofofofofofofofofofofofofremovereplaceAllreversesetsortsortedCopyOfsortedCopyOfsubListUncheckedtoImmutableList

Field Detail

elementback to summary
pack-priv final transient E element

Constructor Detail

SingletonImmutableListback to summary
pack-priv SingletonImmutableList(E element)

Method Detail

getback to summary
public E get(int index)

Implements java.util.List.get.

Doc from java.util.List.get.

Returns the element at the specified position in this list.

Parameters
index:int

index of the element to return

Returns:E

the element at the specified position in this list

Annotations
@Override
isPartialViewback to summary
pack-priv boolean isPartialView()

Implements abstract com.google.common.collect.ImmutableCollection.isPartialView.

Doc from com.google.common.collect.ImmutableCollection.isPartialView.

Returns 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.

Annotations
@Override
iteratorback to summary
public UnmodifiableIterator<E> iterator()

Overrides com.google.common.collect.ImmutableList.iterator.

Implements java.util.List.iterator, java.util.Collection.iterator.

Doc from java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.

Returns:UnmodifiableIterator<E>

an iterator over the elements in this list in proper sequence

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this list

Annotations
@Override
spliteratorback to summary
public Spliterator<E> spliterator()

Overrides com.google.common.collect.ImmutableList.spliterator.

Overrides default java.util.List.spliterator, java.util.Collection.spliterator.

Doc from java.util.List.spliterator.

Creates a Spliterator over the elements in this list.

The Spliterator reports Spliterator#SIZED and Spliterator#ORDERED. Implementations should document the reporting of additional characteristic values.

Returns:Spliterator<E>

a Spliterator over the elements in this list

Annotations
@Override
subListback to summary
public ImmutableList<E> subList(int fromIndex, int toIndex)

Overrides com.google.common.collect.ImmutableList.subList.

Implements java.util.List.subList.

Doc from com.google.common.collect.ImmutableList.subList.

Returns an immutable list of the elements between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the empty immutable list is returned.)

Note

in almost all circumstances, the returned ImmutableList retains a strong reference to this, which may prevent the original list from being garbage collected. If you want the original list to be eligible for garbage collection, you should create and use a copy of the sub list (e.g., ImmutableList.copyOf(originalList.subList(...))).

Parameters
fromIndex:int

Doc from java.util.List.subList.

low endpoint (inclusive) of the subList

toIndex:int

Doc from java.util.List.subList.

high endpoint (exclusive) of the subList

Returns:ImmutableList<E>

Doc from java.util.List.subList.

a view of the specified range within this list

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.util.AbstractCollection.toString.

Doc from java.util.AbstractCollection.toString.

Returns a string representation of this collection. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String#valueOf(Object).

Returns:String

a string representation of this collection

Annotations
@Override
writeReplaceback to summary
pack-priv Object writeReplace()

Overrides com.google.common.collect.ImmutableList.writeReplace.

Annotations
@SuppressWarnings:RedundantOverride
@Override
@J2ktIncompatible
@GwtIncompatible