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:
Serializable
,Iterable<E>
,Collection<E>
,List<E>
,RandomAccess
,SequencedCollection<E>
Implementation of
ImmutableList
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
-
Field Summary
FieldsFields inherited from class com.google.common.collect.ImmutableCollection
SPLITERATOR_CHARACTERISTICS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget
(int index) (package private) boolean
Returnstrue
if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods.iterator()
Returns an unmodifiable iterator across the elements in this collection.int
size()
subList
(int fromIndex, int toIndex) Returns an immutable list of the elements between the specifiedfromIndex
, inclusive, andtoIndex
, exclusive.toString()
(package private) Object
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
Methods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, internalArray, internalArrayEnd, internalArrayStart, remove, removeAll, removeIf, retainAll, toArray, toArray
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Field Details
-
element
-
-
Constructor Details
-
SingletonImmutableList
SingletonImmutableList(E element)
-
-
Method Details
-
get
-
iterator
Description copied from class:ImmutableCollection
Returns an unmodifiable iterator across the elements in this collection. -
spliterator
- Specified by:
spliterator
in interfaceCollection<E>
- Specified by:
spliterator
in interfaceIterable<E>
- Specified by:
spliterator
in interfaceList<E>
- Overrides:
spliterator
in classImmutableList<E>
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceList<E>
- Specified by:
size
in classAbstractCollection<E>
-
subList
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.)Note: in almost all circumstances, the returned
ImmutableList
retains a strong reference tothis
, 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(...))
). -
toString
- Overrides:
toString
in classAbstractCollection<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>
-
writeReplace
Object writeReplace()- Overrides:
writeReplace
in classImmutableList<E>
-