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>
An
AsyncPeekCallbackIterator is an extension of the AsyncPeekIterator interface that can be given a
callback to call after each time it advances. Note that the AsyncPeekCallbackIterator 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
Modifier and TypeMethodDescriptionReturn the callback that this iterator calls before a new result is returned byAsyncIterator.next().voidsetCallback(Consumer<T> callback) Set the callback to the providedConsumer.static <T> AsyncPeekCallbackIterator<T>wrap(AsyncIterator<T> iterator, Consumer<T> callback) Wrap anAsyncIteratorwith anAsyncPeekCallbackIterator.Methods inherited from interface com.apple.foundationdb.async.AsyncIterator
cancel, hasNext, next, onHasNextMethods inherited from interface com.apple.foundationdb.async.AsyncPeekIterator
peekMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Method Details
-
wrap
static <T> AsyncPeekCallbackIterator<T> wrap(@Nonnull AsyncIterator<T> iterator, @Nonnull Consumer<T> callback) Wrap anAsyncIteratorwith anAsyncPeekCallbackIterator. The returned iterator returns the same sequence of elements as the suppliedAsyncIteratorinstance in the same order. The wrapping implementation is free to advance the underlying iterator, so it is unsafe to modifyiteratordirectly 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-AsyncIteratorto wrapcallback- a callback to call whenAsyncIterator.next()produces a result- Returns:
- an iterator over the same values as
iteratorthat supports peek and callback semantics
-
setCallback
Set the callback to the providedConsumer.- Parameters:
callback- a consumer to call when a new result is produced byAsyncIterator.next()
-
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
-