I
- the inner type, i.e. the type of the elements returned by the wrapped/inner list iteratorO
- the outer type, i.e. the type of elements returned by this list iteratorpublic final class TransformingListIterator<I,O> extends Object
ListIterator
which wraps another list iterator and transforms elements from an inner type I
to an
outer type O
and vice versa.
The transformation of null elements of either inner or outer type is fixed to null -> null
. The
transformation functions specified during construction do not have to handle null input elements and are not allowed
to produce a null result.
Constructor and Description |
---|
TransformingListIterator(ListIterator<I> innerListIterator,
Function<? super I,? extends O> transformToOuter,
Function<? super O,? extends I> transformToInner)
Creates a new transforming list iterator.
|
Modifier and Type | Method and Description |
---|---|
void |
add(O element) |
void |
forEachRemaining(Consumer<? super O> action) |
protected ListIterator<I> |
getInnerIterator() |
boolean |
hasNext() |
boolean |
hasPrevious() |
O |
next() |
int |
nextIndex() |
O |
previous() |
int |
previousIndex() |
void |
remove() |
void |
set(O element) |
protected I |
transformToInner(O outerElement)
Transforms an element from the outer type
O to the inner type I . |
protected O |
transformToOuter(I innerElement)
Transforms an element from the inner type
I to the outer type O . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
hasNext, next, remove
forEachRemaining
public TransformingListIterator(ListIterator<I> innerListIterator, Function<? super I,? extends O> transformToOuter, Function<? super O,? extends I> transformToInner)
If the specified list iterator is used by any other instance, the behavior is undefined. The specified transform functions will not be called with null elements and are not allowed to return null.
innerListIterator
- the wrapped/inner list iteratortransformToOuter
- transforms elements from the inner type I
to the outer type O
transformToInner
- transforms elements from the outer type O
to the inner type I
protected ListIterator<I> getInnerIterator()
protected O transformToOuter(I innerElement)
I
to the outer type O
.innerElement
- an element returned by the innerIterator
O
protected I transformToInner(O outerElement)
O
to the inner type I
.outerElement
- an element specified as an argument to a method callI
public boolean hasPrevious()
hasPrevious
in interface ListIterator<O>
public int nextIndex()
nextIndex
in interface ListIterator<O>
public int previousIndex()
previousIndex
in interface ListIterator<O>
public O previous()
previous
in interface ListIterator<O>
public void add(O element)
add
in interface ListIterator<O>
public void set(O element)
set
in interface ListIterator<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.