public class TransformIterator<I,O> extends Object implements Iterator<O>
Constructor and Description |
---|
TransformIterator()
Constructs a new
TransformIterator that will not function
until the setIterator and
setTransformer(Transformer) methods are invoked. |
TransformIterator(Iterator<? extends I> iterator)
Constructs a new
TransformIterator that won't transform
elements from the given iterator. |
TransformIterator(Iterator<? extends I> iterator,
Transformer<? super I,? extends O> transformer)
Constructs a new
TransformIterator that will use the
given iterator and transformer. |
Modifier and Type | Method and Description |
---|---|
Iterator<? extends I> |
getIterator()
Gets the iterator this iterator is using.
|
Transformer<? super I,? extends O> |
getTransformer()
Gets the transformer this iterator is using.
|
boolean |
hasNext() |
O |
next()
Gets the next object from the iteration, transforming it using the
current transformer.
|
void |
remove() |
void |
setIterator(Iterator<? extends I> iterator)
Sets the iterator for this iterator to use.
|
void |
setTransformer(Transformer<? super I,? extends O> transformer)
Sets the transformer this the iterator to use.
|
protected O |
transform(I source)
Transforms the given object using the transformer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public TransformIterator()
TransformIterator
that will not function
until the setIterator
and
setTransformer(Transformer)
methods are invoked.public TransformIterator(Iterator<? extends I> iterator)
TransformIterator
that won't transform
elements from the given iterator.iterator
- the iterator to usepublic TransformIterator(Iterator<? extends I> iterator, Transformer<? super I,? extends O> transformer)
TransformIterator
that will use the
given iterator and transformer. If the given transformer is null,
then objects will not be transformed.iterator
- the iterator to usetransformer
- the transformer to usepublic O next()
next
in interface Iterator<O>
NoSuchElementException
- if there are no more elementspublic Iterator<? extends I> getIterator()
public void setIterator(Iterator<? extends I> iterator)
iterator
- the iterator to usepublic Transformer<? super I,? extends O> getTransformer()
public void setTransformer(Transformer<? super I,? extends O> transformer)
transformer
- the transformer to useCopyright © 2001–2018 The Apache Software Foundation. All rights reserved.