Package com.google.common.collect
Class SingletonImmutableList<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.google.common.collect.ImmutableCollection<E>
-
- com.google.common.collect.ImmutableList<E>
-
- com.google.common.collect.SingletonImmutableList<E>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
,java.util.RandomAccess
@GwtCompatible(serializable=true, emulated=true) final class SingletonImmutableList<E> extends ImmutableList<E>
Implementation ofImmutableList
with exactly one element.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableList
ImmutableList.Builder<E>, ImmutableList.SerializedForm, ImmutableList.SubList
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableCollection
ImmutableCollection.ArrayBasedBuilder<E>
-
-
Constructor Summary
Constructors Constructor Description SingletonImmutableList(E element)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description E
get(int index)
(package private) boolean
isPartialView()
Returnstrue
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()
ImmutableList<E>
subList(int fromIndex, int toIndex)
Returns an immutable list of the elements between the specifiedfromIndex
, inclusive, andtoIndex
, exclusive.java.lang.String
toString()
-
Methods inherited from class com.google.common.collect.ImmutableList
add, addAll, asImmutableList, asImmutableList, asList, builder, contains, copyIntoArray, copyOf, copyOf, copyOf, copyOf, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, of, remove, reverse, set, subListUnchecked, writeReplace
-
Methods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, remove, removeAll, retainAll, toArray, toArray
-
-
-
-
Field Detail
-
element
final transient E element
-
-
Constructor Detail
-
SingletonImmutableList
SingletonImmutableList(E element)
-
-
Method Detail
-
get
public E get(int index)
-
iterator
public UnmodifiableIterator<E> iterator()
Description copied from class:ImmutableCollection
Returns an unmodifiable iterator across the elements in this collection.
-
size
public int size()
-
subList
public ImmutableList<E> subList(int fromIndex, int toIndex)
Description copied from class:ImmutableList
Returns an immutable list of the elements between the specifiedfromIndex
, inclusive, andtoIndex
, exclusive. (IffromIndex
andtoIndex
are equal, the empty immutable list is returned.)- Specified by:
subList
in interfacejava.util.List<E>
- Overrides:
subList
in classImmutableList<E>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<E>
-
isPartialView
boolean isPartialView()
Description copied from class:ImmutableCollection
Returnstrue
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 whethercopyOf
implementations should make an explicit copy to avoid memory leaks.- Specified by:
isPartialView
in classImmutableCollection<E>
-
-