Package com.shri.restinpeace
Interface PaginationStrategy<T>
- Type Parameters:
T- the decoded item type - must match the method'sPage<T>/Stream<T>/Iterator<T>return type's own type argument
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
The programmatic escape hatch for a pagination shape
@Paginated's
closed annotation vocabulary can't express - see
docs/design/pagination-helper.md §6.8 and §10 for exactly which
cases require it. Recognized by declared parameter type on a
Page<T>/Stream<T>/Iterator<T>-returning method, the
same idiom RIP already uses for CompletableFuture<T>/
RipResponse<T> return types - no marker annotation needed:
@GET("/orders")
Page<Order> listOrders(@QueryParam("status") String status,
PaginationStrategy<Order> strategy);
@Paginated and a PaginationStrategy<T> parameter are
mutually exclusive on one method - combining them is a validation error,
the same "config vs. provider, pick one" precedent as
CircuitBreakerConfig/CircuitBreakerProvider.
-
Method Summary
Modifier and TypeMethodDescriptionnextRequest(PaginationContext<T> context) Consulted after every page fetch, including the first, to decide whether to continue and what the next request should look like.
-
Method Details
-
nextRequest
Consulted after every page fetch, including the first, to decide whether to continue and what the next request should look like. The lambda only answers that question - the actual re-invocation, and everything that comes with it (retry, cache, circuit breaker, bulkhead, interceptors), stays owned by the same coordinator the declarative@Paginatedpath uses (§6.9).- Parameters:
context- this page's items and metadata- Returns:
- the next request to issue, or
Optional.empty()if this was the last page
-