Class TransformingIterator<In,Out>
- java.lang.Object
-
- com.identityworksllc.iiq.common.iterators.TransformingIterator<In,Out>
-
- Type Parameters:
In- The input class typeOut- The output class type
- All Implemented Interfaces:
AutoCloseable,Iterator<Out>,sailpoint.tools.CloseableIterator<Out>
- Direct Known Subclasses:
AbstractThreadedObjectIteratorTask.ResultTransformingIterator
public class TransformingIterator<In,Out> extends Object implements AutoCloseable, sailpoint.tools.CloseableIterator<Out>, Iterator<Out>
A class that applies a transformation function to each item of an Iterator before returning it fromIterator.next().Basically the Iterator equivalent of
Stream.map(Function).If you suppress nulls, all null transformed values will be skipped.
This is a read-only iterator and does not support remove().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTransformingIterator.TransformerFunction<In,Out>A functional interface similar toFunction, except throwing an exception
-
Field Summary
Fields Modifier and Type Field Description protected RunnablefinalizerSomething to invoke after the last item is readprotected TransformingIterator.TransformerFunction<In,Out>transformationThe output transformation function
-
Constructor Summary
Constructors Constructor Description TransformingIterator(Iterator<? extends In> input)ConstructorTransformingIterator(Iterator<? extends In> input, TransformingIterator.TransformerFunction<In,Out> transformation)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanhasNext()TransformingIterator<In,Out>ignoreNulls()Sets the ignore nulls flag to trueOutnext()TransformingIterator<In,Out>setFinalizer(Runnable finalizer)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Field Detail
-
transformation
protected TransformingIterator.TransformerFunction<In,Out> transformation
The output transformation function
-
-
Constructor Detail
-
TransformingIterator
public TransformingIterator(Iterator<? extends In> input)
Constructor- Parameters:
input- The iterator being wrapped by this transformer
-
TransformingIterator
public TransformingIterator(Iterator<? extends In> input, TransformingIterator.TransformerFunction<In,Out> transformation)
Constructor- Parameters:
input- The iterator being wrapped by this transformertransformation- The transformation to apply to each element of the input iterator
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacesailpoint.tools.CloseableIterator<In>- See Also:
CloseableIterator.close()
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacesailpoint.tools.CloseableIterator<In>- Specified by:
hasNextin interfaceIterator<In>- See Also:
Iterator.hasNext()
-
ignoreNulls
public TransformingIterator<In,Out> ignoreNulls()
Sets the ignore nulls flag to true
-
next
public Out next()
- Specified by:
nextin interfacesailpoint.tools.CloseableIterator<In>- Specified by:
nextin interfaceIterator<In>- See Also:
Iterator.next()
-
setFinalizer
public TransformingIterator<In,Out> setFinalizer(Runnable finalizer)
-
-