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
An iterator implementing offset and max, for another iterator.
- Since:
- 3.1
- Author:
- Michiel Meeuwissen
-
Nested Class Summary
Nested classes/interfaces inherited from interface nl.vpro.util.CloseableIterator
CloseableIterator.WrappedCloseableIterator<S>, CloseableIterator.WrappedPeekingCloseableIterator<S>
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
The count of the next element.protected Boolean
protected T
protected final long
The maximal value of count.protected com.google.common.collect.PeekingIterator<T>
protected final CloseableIterator<T>
-
Constructor Summary
ModifierConstructorDescriptionprotected
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
Modifier and TypeMethodDescriptionautoClose
(AutoCloseable... closeables) static <T> MaxOffsetIterator.Builder<T>
builder()
void
close()
static <T> CountedMaxOffsetIterator.Builder<T>
protected static <S> Predicate<S>
effectiveCountPredicate
(Predicate<S> countPredicate, boolean countNulls) protected boolean
findNext()
long
boolean
hasNext()
next()
peek()
com.google.common.collect.PeekingIterator<T>
Access to the (peeking) wrapped iterator.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
-
Field Details
-
wrapped
-
peekingWrapped
-
offsetmax
protected final long offsetmaxThe maximal value of count. I.e. offset + max; -
count
protected long countThe count of the next element. First value will be the supplied value of offset. -
hasNext
-
next
-
-
Constructor Details
-
MaxOffsetIterator
-
MaxOffsetIterator
-
MaxOffsetIterator
-
MaxOffsetIterator
-
MaxOffsetIterator
-
-
Method Details
-
effectiveCountPredicate
-
callBack
-
autoClose
-
autoClose
-
hasNext
public boolean hasNext() -
peek
- Specified by:
peek
in interfacecom.google.common.collect.PeekingIterator<T>
-
next
-
findNext
protected boolean findNext() -
remove
public void remove() -
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
toString
-
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
-
builder
-
getOffset
public long getOffset()
-