E - the type of elements held in this streampublic class Stream<E>
extends java.lang.Object
implements java.lang.Iterable<E>
VersionParser,
Lexer,
ExpressionParser| Modifier and Type | Class and Description |
|---|---|
static interface |
Stream.ElementType<E>
The
ElementType interface represents types of the elements
held by this stream and can be used for stream filtering. |
| Constructor and Description |
|---|
Stream(E[] elements)
Constructs a stream containing the specified elements.
|
| Modifier and Type | Method and Description |
|---|---|
E |
consume()
Consumes the next element in this stream.
|
<T extends Stream.ElementType<E>> |
consume(T... expected)
Consumes the next element in this stream
only if it is of the expected types.
|
int |
currentOffset()
Returns the current offset of this stream.
|
java.util.Iterator<E> |
iterator()
Returns an iterator over elements that are left in this stream.
|
E |
lookahead()
Returns the next element in this stream without consuming it.
|
E |
lookahead(int position)
Returns the element at the specified position
in this stream without consuming it.
|
<T extends Stream.ElementType<E>> |
positiveLookahead(T... expected)
Checks if the next element in this stream is of the expected types.
|
<T extends Stream.ElementType<E>> |
positiveLookaheadBefore(Stream.ElementType<E> before,
T... expected)
Checks if there exists an element in this stream of
the expected types before the specified type.
|
<T extends Stream.ElementType<E>> |
positiveLookaheadUntil(int until,
T... expected)
Checks if there is an element in this stream of
the expected types until the specified position.
|
void |
pushBack()
Pushes back one element at a time.
|
E[] |
toArray()
Returns an array containing all of the
elements that are left in this stream.
|
public Stream(E[] elements)
elements - the elements to be streamedpublic E consume()
null if no more elements leftpublic <T extends Stream.ElementType<E>> E consume(T... expected)
T - represents the element type of this stream, removes the
"unchecked generic array creation for varargs parameter"
warningsexpected - the types which are expectedUnexpectedElementException - if the next element is of an unexpected typepublic void pushBack()
public E lookahead()
public E lookahead(int position)
position - the position of the element to returnnull if no more elements leftpublic int currentOffset()
public <T extends Stream.ElementType<E>> boolean positiveLookahead(T... expected)
T - represents the element type of this stream, removes the
"unchecked generic array creation for varargs parameter"
warningsexpected - the expected typestrue if the next element is of the expected types
or false otherwisepublic <T extends Stream.ElementType<E>> boolean positiveLookaheadBefore(Stream.ElementType<E> before, T... expected)
T - represents the element type of this stream, removes the
"unchecked generic array creation for varargs parameter"
warningsbefore - the type before which to searchexpected - the expected typestrue if there is an element of the expected types
before the specified type or false otherwisepublic <T extends Stream.ElementType<E>> boolean positiveLookaheadUntil(int until, T... expected)
T - represents the element type of this stream, removes the
"unchecked generic array creation for varargs parameter"
warningsuntil - the position until which to searchexpected - the expected typestrue if there is an element of the expected types
until the specified position or false otherwisepublic java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E>public E[] toArray()