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 ofImmutableListwith exactly one element.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableList
ImmutableList.Builder<E>, ImmutableList.SerializedForm, ImmutableList.SubList
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Eelement-
Fields inherited from class com.google.common.collect.ImmutableCollection
SPLITERATOR_CHARACTERISTICS
-
-
Constructor Summary
Constructors Constructor Description SingletonImmutableList(E element)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Eget(int index)(package private) booleanisPartialView()Returnstrueif 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.intsize()java.util.Spliterator<E>spliterator()ImmutableList<E>subList(int fromIndex, int toIndex)Returns an immutable list of the elements between the specifiedfromIndex, inclusive, andtoIndex, exclusive.java.lang.StringtoString()-
Methods inherited from class com.google.common.collect.ImmutableList
add, addAll, asImmutableList, asImmutableList, asList, builder, builderWithExpectedSize, contains, copyIntoArray, copyOf, copyOf, copyOf, copyOf, equals, forEach, hashCode, indexOf, lastIndexOf, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, of, remove, replaceAll, reverse, set, sort, sortedCopyOf, sortedCopyOf, subListUnchecked, toImmutableList, writeReplace
-
Methods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, internalArray, internalArrayEnd, internalArrayStart, remove, removeAll, removeIf, 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:ImmutableCollectionReturns an unmodifiable iterator across the elements in this collection.
-
spliterator
public java.util.Spliterator<E> spliterator()
- Specified by:
spliteratorin interfacejava.util.Collection<E>- Specified by:
spliteratorin interfacejava.lang.Iterable<E>- Specified by:
spliteratorin interfacejava.util.List<E>- Overrides:
spliteratorin classImmutableList<E>
-
size
public int size()
-
subList
public ImmutableList<E> subList(int fromIndex, int toIndex)
Description copied from class:ImmutableListReturns an immutable list of the elements between the specifiedfromIndex, inclusive, andtoIndex, exclusive. (IffromIndexandtoIndexare equal, the empty immutable list is returned.)- Specified by:
subListin interfacejava.util.List<E>- Overrides:
subListin classImmutableList<E>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.AbstractCollection<E>
-
isPartialView
boolean isPartialView()
Description copied from class:ImmutableCollectionReturnstrueif 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 whethercopyOfimplementations should make an explicit copy to avoid memory leaks.- Specified by:
isPartialViewin classImmutableCollection<E>
-
-