T
- the element typepublic final class Sequence<T> extends AbstractList<T> implements List<T>, RandomAccess, Serializable
List
, it is in fact
immutable.modCount
Modifier and Type | Method and Description |
---|---|
<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.
|
add, add, addAll, clear, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, add, addAll, addAll, clear, contains, containsAll, indexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray
parallelStream, removeIf, stream
public static <T> Sequence<T> of(T... members)
T
- the element typemembers
- the memberspublic static <T> Sequence<T> of(Collection<T> members)
T
- the element typemembers
- the memberspublic <N> Sequence<N> cast(Class<N> newType) throws ClassCastException
N
- the new typenewType
- the class to cast toClassCastException
- if any elements could not be castpublic static <T> Sequence<T> empty()
T
- the element typepublic int size()
size
in interface Collection<T>
size
in interface List<T>
size
in class AbstractCollection<T>
public boolean isEmpty()
isEmpty
in interface Collection<T>
isEmpty
in interface List<T>
isEmpty
in class AbstractCollection<T>
true
if the sequence has no elementspublic Object[] toArray()
toArray
in interface Collection<T>
toArray
in interface List<T>
toArray
in class AbstractCollection<T>
public T get(int index)
public boolean equals(Object other)
equals
in interface Collection<T>
equals
in interface List<T>
equals
in class AbstractList<T>
other
- the other sequencetrue
if they are equal, false
otherwisepublic boolean equals(Sequence<?> other)
other
- the other sequencetrue
if they are equal, false
otherwisepublic int hashCode()
hashCode
in interface Collection<T>
hashCode
in interface List<T>
hashCode
in class AbstractList<T>
Copyright © 2016 JBoss by Red Hat. All rights reserved.