Interface PageCallback<T,R>

Type Parameters:
R - the type of the possibly null value to be returned from onEnd(PageSummary)
All Known Implementing Classes:
AbstractPageCallback
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface PageCallback<T,R>
A callback for iterating through a stream of items. After an initial call to signify zero or more items are to follow, the callback is repeatedly called with an item until the last one is processed in the stream or until CallbackResult.DONE is returned by onItem(Object). At the end of processing, onEnd(PageSummary) is called and any value it returned deemed, by the enclosing call or method, as the result of the stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    default R
    onEnd(PageSummary summary)
    Called after the last item has been passed to this callback (or if no item are to be passed then immediately after onStart(PageRequest).
    onItem(T item)
    Called exactly once for each item that matches any criteria or other qualifier of the enclosing call or process
    default void
    onStart(PageRequest pageRequest)
    Called before the first item is encountered.
  • Method Details

    • onStart

      default void onStart(@Nonnull PageRequest pageRequest)
      Called before the first item is encountered. Note that this will be called even if no item is passed to this callback (for instance if any associated criteria with the streaming operation failed to find matching items).
    • onItem

      @Nonnull CallbackResult onItem(@Nonnull T item)
      Called exactly once for each item that matches any criteria or other qualifier of the enclosing call or process
      Parameters:
      item - the current item
      Returns:
      CallbackResult.CONTINUE if the next item should be processed or CallbackResult.DONE to indicate premature termination of the streaming operation
    • onEnd

      default R onEnd(@Nonnull PageSummary summary)
      Called after the last item has been passed to this callback (or if no item are to be passed then immediately after onStart(PageRequest).
      Returns:
      any result the callback wishes the enclosing call or process to return to its caller or null if no such result is to be supplied (or if the result is in fact null)