Package nl.vpro.util
Class MaxOffsetIterator<T>
- java.lang.Object
-
- nl.vpro.util.MaxOffsetIterator<T>
-
- All Implemented Interfaces:
com.google.common.collect.PeekingIterator<T>
,AutoCloseable
,Iterator<T>
,CloseableIterator<T>
,CloseablePeekingIterator<T>
- Direct Known Subclasses:
CountedMaxOffsetIterator
public class MaxOffsetIterator<T> extends Object implements CloseablePeekingIterator<T>
An iterator implementing offset and max, for another iterator.- Since:
- 3.1
- Author:
- Michiel Meeuwissen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MaxOffsetIterator.Builder<T>
-
Nested classes/interfaces inherited from interface nl.vpro.util.CloseableIterator
CloseableIterator.WrappedCloseableIterator<S>, CloseableIterator.WrappedPeekingCloseableIterator<S>
-
-
Field Summary
Fields Modifier and Type Field Description protected long
count
The count of the next element.protected Boolean
hasNext
protected T
next
protected long
offsetmax
The maximal value of count.protected com.google.common.collect.PeekingIterator<T>
peekingWrapped
protected CloseableIterator<T>
wrapped
-
Constructor Summary
Constructors Modifier Constructor Description protected
MaxOffsetIterator(@NonNull Iterator<T> wrapped, @Nullable Number max, @Nullable Number offset, @Nullable Predicate<T> countPredicate, boolean countNulls, @Nullable List<Runnable> callbacks, boolean autoClose)
MaxOffsetIterator(Iterator<T> wrapped, Number max)
MaxOffsetIterator(Iterator<T> wrapped, Number max, boolean countNulls)
MaxOffsetIterator(Iterator<T> wrapped, Number max, Number offset)
MaxOffsetIterator(Iterator<T> wrapped, Number max, Number offset, boolean countNulls)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MaxOffsetIterator<T>
autoClose()
MaxOffsetIterator<T>
autoClose(AutoCloseable... closeables)
static <T> MaxOffsetIterator.Builder<T>
builder()
MaxOffsetIterator<T>
callBack(Runnable run)
void
close()
static <T> CountedMaxOffsetIterator.Builder<T>
countedBuilder()
protected static <S> Predicate<S>
effectiveCountPredicate(Predicate<S> countPredicate, boolean countNulls)
protected boolean
findNext()
long
getOffset()
boolean
hasNext()
T
next()
T
peek()
com.google.common.collect.PeekingIterator<T>
peekingWrapped()
Access to the (peeking) wrapped iterator.void
remove()
String
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
-
-
-
-
Field Detail
-
wrapped
protected final CloseableIterator<T> wrapped
-
peekingWrapped
protected com.google.common.collect.PeekingIterator<T> peekingWrapped
-
offsetmax
protected final long offsetmax
The maximal value of count. I.e. offset + max;
-
count
protected long count
The count of the next element. First value will be the supplied value of offset.
-
hasNext
protected Boolean hasNext
-
next
protected T next
-
-
Method Detail
-
effectiveCountPredicate
protected static <S> Predicate<S> effectiveCountPredicate(Predicate<S> countPredicate, boolean countNulls)
-
callBack
public MaxOffsetIterator<T> callBack(Runnable run)
-
autoClose
public MaxOffsetIterator<T> autoClose(AutoCloseable... closeables)
-
autoClose
public MaxOffsetIterator<T> autoClose()
-
next
public T next()
-
findNext
protected boolean findNext()
-
remove
public void remove()
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
peekingWrapped
public com.google.common.collect.PeekingIterator<T> peekingWrapped()
Access to the (peeking) wrapped iterator. This may be used to look 'beyond' max, to check what would have been the next one.
-
countedBuilder
public static <T> CountedMaxOffsetIterator.Builder<T> countedBuilder()
-
builder
public static <T> MaxOffsetIterator.Builder<T> builder()
-
getOffset
public long getOffset()
-
-