Top Description Fields Constructors Methods
org.xnio

public final Class Sequence<T>

extends AbstractList<T>
implements List<T>, RandomAccess, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.util.RandomAccess, java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable
Type Parameters
<T>
the element type
Imports
java.io.Serializable, java.util.Iterator, .Arrays, .Collection, .AbstractList, .List, .RandomAccess

An immutable sequence of elements. Though this class implements java.util.List, it is in fact immutable.

Field Summary

Modifier and TypeField and Description
private static final Object[]
private static final Sequence<?>
private static final long
private final Object[]
Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
private
Sequence(final Object[] values)

Method Summary

Modifier and TypeMethod and Description
public <
the new type
N
>
Sequence<N>

Returns:

the typecast sequence
cast
(Class<N>
the class to cast to
newType
)

Cast a sequence to a different type if all the contained elements are of the subtype.

public static <
the element type
T
>
Sequence<T>

Returns:

the empty sequence
empty
()

Return an empty sequence.

public boolean

Returns:

true if they are equal, false otherwise
equals
(Object
the other sequence
other
)

Overrides java.util.AbstractList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Determine whether this sequence is equal to another.

public boolean

Returns:

true if they are equal, false otherwise
equals
(Sequence<?>
the other sequence
other
)

Determine whether this sequence is equal to another.

public T

Returns:

the value
get
(final int
the index
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Get the value at a certain index.

public int

Returns:

the hash code
hashCode
()

Overrides java.util.AbstractList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Get the hash code for this sequence.

public boolean

Returns:

true if the sequence has no elements
isEmpty
()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.List.isEmpty, java.util.Collection.isEmpty.

Determine whether this sequence is empty.

public Iterator<T>

Returns:

an iterator over the elements of this sequence
iterator
()

Overrides java.util.AbstractList.iterator.

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

Get an iterator over the elements of this sequence.

public static <
the element type
T
>
Sequence<T>

Returns:

a sequence
of
(T...
the members
members
)

Hides java.util.List.of, java.util.List.of.

Return a sequence of the given members.

public static <
the element type
T
>
Sequence<T>

Returns:

a sequence
of
(Collection<T>
the members
members
)

Hides java.util.List.of.

Return a sequence of the given members.

public int

Returns:

the number of elements
size
()

Implements abstract java.util.AbstractCollection.size.

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

Return the number of elements in this sequence.

public Object[]

Returns:

a copy of the values array
toArray
()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.List.toArray, java.util.Collection.toArray.

Get a copy of the values array.

Inherited from java.util.AbstractList:
addaddaddAllclearindexOflastIndexOflistIteratorlistIteratorremoveremoveRangesetsubList

Field Detail

emptyback to summary
private static final Object[] empty
EMPTYback to summary
private static final Sequence<?> EMPTY
serialVersionUIDback to summary
private static final long serialVersionUID
valuesback to summary
private final Object[] values

Constructor Detail

Sequenceback to summary
private Sequence(final Object[] values)

Method Detail

castback to summary
public <N> Sequence<N> cast(Class<N> newType) throws ClassCastException

Cast a sequence to a different type if all the contained elements are of the subtype.

Parameters
<N>
the new type
newType:Class<N>

the class to cast to

Returns:Sequence<N>

the typecast sequence

Annotations
@SuppressWarnings:unchecked
Exceptions
ClassCastException:
if any elements could not be cast
emptyback to summary
public static <T> Sequence<T> empty()

Return an empty sequence.

Parameters
<T>
the element type
Returns:Sequence<T>

the empty sequence

Annotations
@SuppressWarnings:unchecked
equalsback to summary
public boolean equals(Object other)

Overrides java.util.AbstractList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Determine whether this sequence is equal to another.

Parameters
other:Object

the other sequence

Returns:boolean

true if they are equal, false otherwise

equalsback to summary
public boolean equals(Sequence<?> other)

Determine whether this sequence is equal to another.

Parameters
other:Sequence<?>

the other sequence

Returns:boolean

true if they are equal, false otherwise

getback to summary
public T get(final int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Get the value at a certain index.

Parameters
index:int

the index

Returns:T

the value

Annotations
@SuppressWarnings:unchecked
hashCodeback to summary
public int hashCode()

Overrides java.util.AbstractList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Get the hash code for this sequence.

Returns:int

the hash code

isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.List.isEmpty, java.util.Collection.isEmpty.

Determine whether this sequence is empty.

Returns:boolean

true if the sequence has no elements

iteratorback to summary
public Iterator<T> iterator()

Overrides java.util.AbstractList.iterator.

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

Get an iterator over the elements of this sequence.

Returns:Iterator<T>

an iterator over the elements of this sequence

Annotations
@SuppressWarnings:unchecked
ofback to summary
public static <T> Sequence<T> of(T... members)

Hides java.util.List.of, java.util.List.of.

Return a sequence of the given members.

Parameters
<T>
the element type
members:T[]

the members

Returns:Sequence<T>

a sequence

ofback to summary
public static <T> Sequence<T> of(Collection<T> members)

Hides java.util.List.of.

Return a sequence of the given members.

Parameters
<T>
the element type
members:Collection<T>

the members

Returns:Sequence<T>

a sequence

sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

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

Return the number of elements in this sequence.

Returns:int

the number of elements

toArrayback to summary
public Object[] toArray()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.List.toArray, java.util.Collection.toArray.

Get a copy of the values array.

Returns:Object[]

a copy of the values array