Package nl.vpro.util
Class FilteringIterator<T>
java.lang.Object
nl.vpro.util.FilteringIterator<T>
- All Implemented Interfaces:
AutoCloseable
,Iterator<T>
,CloseableIterator<T>
Filtering, or Transforming iterator.
- Since:
- 1.3
- Author:
- Michiel Meeuwissen
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Nested classes/interfaces inherited from interface nl.vpro.util.CloseableIterator
CloseableIterator.WrappedCloseableIterator<S>, CloseableIterator.WrappedPeekingCloseableIterator<S>
-
Constructor Summary
ConstructorDescriptionFilteringIterator
(Iterator<? extends T> wrapped, Predicate<? super T> filter) FilteringIterator
(Iterator<? extends T> wrapped, Predicate<? super T> filter, FilteringIterator.KeepAlive keepAlive) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> FilteringIterator.Builder<T>
builder()
void
close()
long
long
boolean
hasNext()
static FilteringIterator.KeepAlive
static FilteringIterator.KeepAlive
static FilteringIterator.KeepAlive
keepAliveChars
(long c, Function<Character, Boolean> callback) This translates the 'numberOfRecords' to a character to write if no records are outputted by the iterated since the last call to the callback.static FilteringIterator.KeepAlive
keepAliveChars
(Function<Character, Boolean> callback) static FilteringIterator.KeepAlive
keepAliveWithoutBreaks
(long c, LongConsumer callback) static FilteringIterator.KeepAlive
keepAliveWithoutBreaks
(LongConsumer callback) next()
static FilteringIterator.KeepAlive
void
remove()
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface nl.vpro.util.CloseableIterator
peeking, stream
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
FilteringIterator
-
FilteringIterator
public FilteringIterator(Iterator<? extends T> wrapped, Predicate<? super T> filter, FilteringIterator.KeepAlive keepAlive)
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
noKeepAlive
-
keepAliveWithoutBreaks
-
keepAliveWithoutBreaks
-
keepAlive
-
keepAliveChars
-
keepAliveChars
public static FilteringIterator.KeepAlive keepAliveChars(long c, Function<Character, Boolean> callback) This translates the 'numberOfRecords' to a character to write if no records are outputted by the iterated since the last call to the callback. The callback is called with the character. The idea is to write it simply to the stream, to keep it 'alive. The use case is in MediaRestServiceImpl#iterate- Parameters:
c
-callback
-- Returns:
-
keepAlive
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
toString
-
builder
-
getSkipped
public long getSkipped() -
getPassed
public long getPassed()
-