Package com.apple.foundationdb.async
Interface AsyncPeekCallbackIterator<T>
-
- Type Parameters:
T
- type of elements returned by the scan
- All Superinterfaces:
AsyncIterator<T>
,AsyncPeekIterator<T>
,Iterator<T>
public interface AsyncPeekCallbackIterator<T> extends AsyncPeekIterator<T>
AnAsyncPeekCallbackIterator
is an extension of theAsyncPeekIterator
interface that can be given a callback to call after each time it advances. Note that theAsyncPeekCallbackIterator
is mostly a tag interface and does not contain any logic for executing the callback after yielding each result; conforming implementations must implement that logic.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Consumer<T>
getCallback()
Return the callback that this iterator calls before a new result is returned byAsyncIterator.next()
.void
setCallback(Consumer<T> callback)
Set the callback to the providedConsumer
.static <T> AsyncPeekCallbackIterator<T>
wrap(AsyncIterator<T> iterator, Consumer<T> callback)
Wrap anAsyncIterator
with anAsyncPeekCallbackIterator
.-
Methods inherited from interface com.apple.foundationdb.async.AsyncIterator
cancel, hasNext, next, onHasNext
-
Methods inherited from interface com.apple.foundationdb.async.AsyncPeekIterator
peek
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Method Detail
-
wrap
static <T> AsyncPeekCallbackIterator<T> wrap(@Nonnull AsyncIterator<T> iterator, @Nonnull Consumer<T> callback)
Wrap anAsyncIterator
with anAsyncPeekCallbackIterator
. The returned iterator returns the same sequence of elements as the suppliedAsyncIterator
instance in the same order. The wrapping implementation is free to advance the underlying iterator, so it is unsafe to modifyiterator
directly after calling this method. The returned iterator is also not thread safe, so concurrent calls toonHasNext
, for example, may lead to unexpected behavior.- Type Parameters:
T
- type of items returned by the scan- Parameters:
iterator
-AsyncIterator
to wrapcallback
- a callback to call whenAsyncIterator.next()
produces a result- Returns:
- an iterator over the same values as
iterator
that supports peek and callback semantics
-
setCallback
void setCallback(@Nonnull Consumer<T> callback)
Set the callback to the providedConsumer
.- Parameters:
callback
- a consumer to call when a new result is produced byAsyncIterator.next()
-
getCallback
@Nonnull Consumer<T> getCallback()
Return the callback that this iterator calls before a new result is returned byAsyncIterator.next()
.- Returns:
- the callback that this iterator calls before a new result is returned by
AsyncIterator.next()
;W
-
-