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 interface
TransformingIterator.TransformerFunction<In,Out>
A functional interface similar toFunction
, except throwing an exception
-
Field Summary
Fields Modifier and Type Field Description protected Runnable
finalizer
Something to invoke after the last item is readprotected TransformingIterator.TransformerFunction<In,Out>
transformation
The 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 void
close()
boolean
hasNext()
TransformingIterator<In,Out>
ignoreNulls()
Sets the ignore nulls flag to trueOut
next()
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfacesailpoint.tools.CloseableIterator<In>
- See Also:
CloseableIterator.close()
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacesailpoint.tools.CloseableIterator<In>
- Specified by:
hasNext
in 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:
next
in interfacesailpoint.tools.CloseableIterator<In>
- Specified by:
next
in interfaceIterator<In>
- See Also:
Iterator.next()
-
setFinalizer
public TransformingIterator<In,Out> setFinalizer(Runnable finalizer)
-
-