XNIO API 2.0.2.GA

org.jboss.xnio
Class Sequence<T>

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

public final class Sequence<T>
extends java.util.AbstractList<T>
implements java.util.List<T>, java.util.RandomAccess, java.io.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(java.lang.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.
 T get(int index)
          Get the value at a certain index.
 boolean isEmpty()
          Determine whether this sequence is empty.
 java.util.Iterator<T> iterator()
          Get an iterator over the elements of this sequence.
static
<T> Sequence<T>
of(java.util.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.
 java.lang.Object[] toArray()
          Get a copy of the values array.
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, 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, equals, hashCode, 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(java.util.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(java.lang.Class<N> newType)
                 throws java.lang.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:
java.lang.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 java.util.Iterator<T> iterator()
Get an iterator over the elements of this sequence.

Specified by:
iterator in interface java.lang.Iterable<T>
Specified by:
iterator in interface java.util.Collection<T>
Specified by:
iterator in interface java.util.List<T>
Overrides:
iterator in class java.util.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 java.util.Collection<T>
Specified by:
size in interface java.util.List<T>
Specified by:
size in class java.util.AbstractCollection<T>
Returns:
the number of elements

isEmpty

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

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

toArray

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

Specified by:
toArray in interface java.util.Collection<T>
Specified by:
toArray in interface java.util.List<T>
Overrides:
toArray in class java.util.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 java.util.List<T>
Specified by:
get in class java.util.AbstractList<T>
Parameters:
index - the index
Returns:
the value

XNIO API 2.0.2.GA

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