Class TransformIterator<I,O> 
java.lang.Object
org.apache.commons.collections4.iterators.TransformIterator<I,O> 
- Type Parameters:
- I- the type of the input to the function.
- O- the type of the result of the function.
- All Implemented Interfaces:
- Iterator<O>
Decorates an iterator such that each element returned is transformed.
- Since:
- 1.0
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a newTransformIteratorthat will not function until thesetIteratorandsetTransformer(Transformer)methods are invoked.TransformIterator(Iterator<? extends I> iterator) Constructs a newTransformIteratorthat won't transform elements from the given iterator.TransformIterator(Iterator<? extends I> iterator, Transformer<? super I, ? extends O> transformer) Constructs a newTransformIteratorthat will use the given iterator and transformer.
- 
Method SummaryModifier and TypeMethodDescriptionGets the iterator this iterator is using.Transformer<? super I, ? extends O> Gets the transformer this iterator is using.booleanhasNext()next()Gets the next object from the iteration, transforming it using the current transformer.voidremove()voidsetIterator(Iterator<? extends I> iterator) Sets the iterator for this iterator to use.voidsetTransformer(Transformer<? super I, ? extends O> transformer) Sets the transformer this the iterator to use.protected OTransforms the given object using the transformer.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.IteratorforEachRemaining
- 
Constructor Details- 
TransformIteratorpublic TransformIterator()Constructs a newTransformIteratorthat will not function until thesetIteratorandsetTransformer(Transformer)methods are invoked.
- 
TransformIteratorConstructs a newTransformIteratorthat won't transform elements from the given iterator.- Parameters:
- iterator- the iterator to use
 
- 
TransformIteratorpublic TransformIterator(Iterator<? extends I> iterator, Transformer<? super I, ? extends O> transformer) Constructs a newTransformIteratorthat will use the given iterator and transformer. If the given transformer is null, then objects will not be transformed.- Parameters:
- iterator- the iterator to use
- transformer- the transformer to use
 
 
- 
- 
Method Details- 
getIteratorGets the iterator this iterator is using.- Returns:
- the iterator.
 
- 
getTransformerGets the transformer this iterator is using.- Returns:
- the transformer.
 
- 
hasNext
- 
nextGets the next object from the iteration, transforming it using the current transformer. If the transformer is null, no transformation occurs and the object from the iterator is returned directly.- Specified by:
- nextin interface- Iterator<I>
- Returns:
- the next object
- Throws:
- NoSuchElementException- if there are no more elements
 
- 
remove
- 
setIteratorSets the iterator for this iterator to use. If iteration has started, this effectively resets the iterator.- Parameters:
- iterator- the iterator to use
 
- 
setTransformerSets the transformer this the iterator to use. A null transformer is a no-op transformer.- Parameters:
- transformer- the transformer to use
 
- 
transform
 
-