XNIO API 3.0.4.GA

org.xnio
Class Sequence<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<T>
          extended by org.xnio.Sequence<T>
Type Parameters:
T - the element type
All Implemented Interfaces:
Serializable, Iterable<T>, Collection<T>, List<T>, RandomAccess

public final class Sequence<T>
extends AbstractList<T>
implements List<T>, RandomAccess, Serializable

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

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Method Summary
<N> Sequence<N>
cast(Class<N> newType)
          Cast a sequence to a different type if all the contained elements are of the subtype.
static
<T> Sequence<T>
empty()
          Return an empty sequence.
 boolean equals(Object other)
          Determine whether this sequence is equal to another.
 boolean equals(Sequence<?> other)
          Determine whether this sequence is equal to another.
 T get(int index)
          Get the value at a certain index.
 int hashCode()
          Get the hash code for this sequence.
 boolean isEmpty()
          Determine whether this sequence is empty.
 Iterator<T> iterator()
          Get an iterator over the elements of this sequence.
static
<T> Sequence<T>
of(Collection<T> members)
          Return a sequence of the given members.
static
<T> Sequence<T>
of(T... members)
          Return a sequence of the given members.
 int size()
          Return the number of elements in this sequence.
 Object[] toArray()
          Get a copy of the values array.
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, indexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray
 

Method Detail

of

public static <T> Sequence<T> of(T... members)
Return a sequence of the given members.

Type Parameters:
T - the element type
Parameters:
members - the members
Returns:
a sequence

of

public static <T> Sequence<T> of(Collection<T> members)
Return a sequence of the given members.

Type Parameters:
T - the element type
Parameters:
members - the members
Returns:
a sequence

cast

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.

Type Parameters:
N - the new type
Parameters:
newType - the class to cast to
Returns:
the typecast sequence
Throws:
ClassCastException - if any elements could not be cast

empty

public static <T> Sequence<T> empty()
Return an empty sequence.

Type Parameters:
T - the element type
Returns:
the empty sequence

iterator

public Iterator<T> iterator()
Get an iterator over the elements of this sequence.

Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Collection<T>
Specified by:
iterator in interface List<T>
Overrides:
iterator in class AbstractList<T>
Returns:
an iterator over the elements of this sequence

size

public int size()
Return the number of elements in this sequence.

Specified by:
size in interface Collection<T>
Specified by:
size in interface List<T>
Specified by:
size in class AbstractCollection<T>
Returns:
the number of elements

isEmpty

public boolean isEmpty()
Determine whether this sequence is empty.

Specified by:
isEmpty in interface Collection<T>
Specified by:
isEmpty in interface List<T>
Overrides:
isEmpty in class AbstractCollection<T>
Returns:
true if the sequence has no elements

toArray

public Object[] toArray()
Get a copy of the values array.

Specified by:
toArray in interface Collection<T>
Specified by:
toArray in interface List<T>
Overrides:
toArray in class AbstractCollection<T>
Returns:
a copy of the values array

get

public T get(int index)
Get the value at a certain index.

Specified by:
get in interface List<T>
Specified by:
get in class AbstractList<T>
Parameters:
index - the index
Returns:
the value

equals

public boolean equals(Object other)
Determine whether this sequence is equal to another.

Specified by:
equals in interface Collection<T>
Specified by:
equals in interface List<T>
Overrides:
equals in class AbstractList<T>
Parameters:
other - the other sequence
Returns:
true if they are equal, false otherwise

equals

public boolean equals(Sequence<?> other)
Determine whether this sequence is equal to another.

Parameters:
other - the other sequence
Returns:
true if they are equal, false otherwise

hashCode

public int hashCode()
Get the hash code for this sequence.

Specified by:
hashCode in interface Collection<T>
Specified by:
hashCode in interface List<T>
Overrides:
hashCode in class AbstractList<T>
Returns:
the hash code

XNIO API 3.0.4.GA

Copyright © 2010 JBoss, a division of Red Hat, Inc.