Top Description Fields Constructors Methods
org.eclipse.collections.impl.list.immutable

pack-priv final Class ImmutableDoubletonList<T>

extends AbstractImmutableList<T>
implements Serializable, RandomAccess
Class Inheritance
All Implemented Interfaces
java.util.RandomAccess, java.io.Serializable
Imports
java.io.Serializable, java.util.Objects, .RandomAccess, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.factory.Lists, org.eclipse.collections.api.list.ImmutableList

This is a two element immutable List which is created by calling Immutable.newListWith(one, two) method.

Field Summary

Modifier and TypeField and Description
private final T
private final T
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
ImmutableDoubletonList(T obj1, T obj2)

Method Summary

Modifier and TypeMethod and Description
public boolean
public void
each(Procedure<? super T> procedure)

Implements org.eclipse.collections.api.RichIterable.each.

The procedure is executed for each element in the iterable.

public T
get(int index)

Implements org.eclipse.collections.api.list.ListIterable.get, java.util.List.get.

Returns the element at the specified position in this list.

public T
public T
public T
getOnly()

Overrides default org.eclipse.collections.api.RichIterable.getOnly.

Returns the element if the iterable has exactly one element.

public ImmutableList<T>
newWith(T newItem)

Implements org.eclipse.collections.api.list.ImmutableList.newWith, org.eclipse.collections.api.collection.ImmutableCollection.newWith.

This method is similar to the with method in MutableCollection with the difference that a new copy of this collection with the element appended will be returned.

public int
size()

Implements org.eclipse.collections.api.RichIterable.size, java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.

Inherited from org.eclipse.collections.impl.list.immutable.AbstractImmutableList:
addaddAllappendStringasParallelasReversedcastToListchunkcollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithcollectWithcorrespondscountdetectIndexdetectLastIndexdistinctdistinctdistinctBydropdropWhileequalsflatCollectflatCollectforEachforEachWithforEachWithIndexforEachWithIndexgroupBygroupBygroupByEachgroupByEachhashCodeindexOfinjectIntoinjectIntoinjectIntoinjectIntoinjectIntoiteratorlastIndexOflistIteratorlistIteratormaxmaxmaxByminminminBynewMutablenewWithAllnewWithoutnewWithoutAllpartitionpartitionWhilepartitionWithregularListEqualsrejectrejectWithrejectWithremovereplaceAllselectselectInstancesOfselectWithselectWithsetsortsubListsumOfDoublesumOfFloatsumOfIntsumOfLongtaketakeWhiletaptoImmutabletoReversedzipzipWithIndex

Field Detail

element1back to summary
private final T element1
element2back to summary
private final T element2
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ImmutableDoubletonListback to summary
pack-priv ImmutableDoubletonList(T obj1, T obj2)

Method Detail

containsback to summary
public boolean contains(Object obj)

Overrides org.eclipse.collections.impl.AbstractRichIterable.contains.

Implements org.eclipse.collections.api.RichIterable.contains, java.util.List.contains, java.util.Collection.contains.

Doc from java.util.List.contains.

Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that Objects.equals(o, e).

Annotations
@Override
eachback to summary
public void each(Procedure<? super T> procedure)

Implements org.eclipse.collections.api.RichIterable.each.

Doc from org.eclipse.collections.api.RichIterable.each.

The procedure is executed for each element in the iterable.

Example using a Java 8 lambda expression:

people.each(person -> LOGGER.info(person.getName()));
This method is a variant of InternalIterable#forEach(Procedure) that has a signature conflict with Iterable#forEach(java.util.function.Consumer).
Annotations
@Override
getback to summary
public T get(int index)

Implements org.eclipse.collections.api.list.ListIterable.get, java.util.List.get.

Doc from java.util.List.get.

Returns the element at the specified position in this list.

Annotations
@Override
getFirstback to summary
public T getFirst()

Overrides org.eclipse.collections.impl.list.immutable.AbstractImmutableList.getFirst.

Overrides default java.util.List.getFirst.

Implements org.eclipse.collections.api.RichIterable.getFirst, org.eclipse.collections.api.list.ListIterable.getFirst.

Doc from java.util.List.getFirst.

Gets the first element of this collection.

Annotations
@Override
getLastback to summary
public T getLast()

Overrides org.eclipse.collections.impl.list.immutable.AbstractImmutableList.getLast.

Overrides default java.util.List.getLast.

Implements org.eclipse.collections.api.RichIterable.getLast, org.eclipse.collections.api.list.ListIterable.getLast.

Doc from java.util.List.getLast.

Gets the last element of this collection.

Annotations
@Override
getOnlyback to summary
public T getOnly()

Overrides default org.eclipse.collections.api.RichIterable.getOnly.

Doc from org.eclipse.collections.api.RichIterable.getOnly.

Returns the element if the iterable has exactly one element. Otherwise, throw IllegalStateException.

Annotations
@Override
newWithback to summary
public ImmutableList<T> newWith(T newItem)

Implements org.eclipse.collections.api.list.ImmutableList.newWith, org.eclipse.collections.api.collection.ImmutableCollection.newWith.

Doc from org.eclipse.collections.api.collection.ImmutableCollection.newWith.

This method is similar to the with method in MutableCollection with the difference that a new copy of this collection with the element appended will be returned.

Annotations
@Override
sizeback to summary
public int size()

Implements org.eclipse.collections.api.RichIterable.size, 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.

Annotations
@Override