I
- the inner type, i.e. the type of the elements returned by the wrapped/inner iteratorO
- the outer type, i.e. the type of elements returned by this iteratorpublic final class TransformingIterator<I,O> extends Object
Iterator
which wraps another iterator and transforms the returned elements from their inner type I
to an outer type O
.
The transformation of null elements is fixed to null -> null
. The transformation function specified during
construction does not have to handle null input elements and is not allowed to produce a null result.
Constructor and Description |
---|
TransformingIterator(Iterator<? extends I> innerIterator,
Function<? super I,? extends O> transformToOuter)
Creates a new iterator.
|
Modifier and Type | Method and Description |
---|---|
void |
forEachRemaining(Consumer<? super O> action) |
protected Iterator<? extends I> |
getInnerIterator() |
boolean |
hasNext() |
O |
next() |
void |
remove() |
protected O |
transformToOuter(I innerElement)
Transforms an element from the inner type
I to the outer type O . |
public TransformingIterator(Iterator<? extends I> innerIterator, Function<? super I,? extends O> transformToOuter)
If the specified iterator is used by any other instance, the behavior is undefined. The specified transform function will not be called with null elements and is not allowed to return null.
innerIterator
- the wrapped/inner iteratortransformToOuter
- transforms elements from the inner type I
to the outer type O
protected Iterator<? extends I> getInnerIterator()
protected O transformToOuter(I innerElement)
I
to the outer type O
.innerElement
- an element returned by the innerIterator
O
public void forEachRemaining(Consumer<? super O> action)
forEachRemaining
in interface Iterator<O>
This documentation is licensed under CC-BY 4.0, attributed to Nicolai Parlog from CodeFX.