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>
    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 Detail

      • wrap

        static <T> AsyncPeekCallbackIterator<T> wrap​(@Nonnull
                                                     AsyncIterator<T> iterator,
                                                     @Nonnull
                                                     Consumer<T> callback)
        Wrap an AsyncIterator with an AsyncPeekCallbackIterator. The returned iterator returns the same sequence of elements as the supplied AsyncIterator instance in the same order. The wrapping implementation is free to advance the underlying iterator, so it is unsafe to modify iterator directly after calling this method. The returned iterator is also not thread safe, so concurrent calls to onHasNext, for example, may lead to unexpected behavior.
        Type Parameters:
        T - type of items returned by the scan
        Parameters:
        iterator - AsyncIterator to wrap
        callback - a callback to call when AsyncIterator.next() produces a result
        Returns:
        an iterator over the same values as iterator that supports peek and callback semantics