T - The type of the wrapped elementspublic class IteratorWrapper<T> extends Object implements Iterator<T>
Iterator that allows easy filtering and mapping of
the returned elements. To achieve this, the original iterable is wrapped into
more and more layers of FilteredIterators and MappedIterators
so that the evaluation of additional layers is only ever performed when the
iterator is actually iterated over. The remove() method is delegated
to the original iterator’s method.| Constructor and Description |
|---|
IteratorWrapper(Iterator<T> iterator)
Creates a new wrapper around the given iterator.
|
| Modifier and Type | Method and Description |
|---|---|
IteratorWrapper<T> |
filter(Filter<? super T> filter)
Creates a new iterator wrapper that will apply the given filter to all
values returned by this wrapper’s iterator.
|
boolean |
hasNext() |
<O> IteratorWrapper<O> |
map(Mapper<? super T,? extends O> mapper)
Creates a new iterator wrapper that will apply the given mapper to all
values returned by this wrapper’s iterator.
|
T |
next() |
IteratorWrapper<T> |
process(Processor<? super T> processor)
Creates a new iterator wrapper that will process all values returned by
this wrapper’s iterator with the given processor.
|
void |
remove() |
static <T> IteratorWrapper<T> |
wrap(Iterator<T> iterator)
Convenience method that creates a new
IteratorWrapper around the
given iterator. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic IteratorWrapper<T> filter(Filter<? super T> filter)
filter - The filter to apply on this iteratorpublic <O> IteratorWrapper<O> map(Mapper<? super T,? extends O> mapper)
O - The type of the mapped elementsmapper - The mapper to apply on this iteratorpublic IteratorWrapper<T> process(Processor<? super T> processor)
processor - The processor to apply on this iteratorpublic static <T> IteratorWrapper<T> wrap(Iterator<T> iterator)
IteratorWrapper around the
given iterator.iterator - The iterator to wrapCopyright © 2026. All rights reserved.