/** * Returns a new query with the new offset as offset. * * @param offset the number of items which should be omitted in the query result. * @return a new query * @throws java.lang.IllegalArgumentException if offset is * not between {@value io.sphere.sdk.queries.Query#MIN_OFFSET} and {@value io.sphere.sdk.queries.Query#MAX_OFFSET}. */ default C withOffset(final long offset) { return withOffset(Long.valueOf(offset)); } }
public static <I> QueryDsl<I> nextPage(final QueryDsl<I> current) { final long oldOffset = current.offset().orElse(0L); return current.withOffset(oldOffset + 1); } }
/** * Gets the results of {@link this} instance's query for a specific page with {@code pageNumber}. * * @param client the CTP client that the query is run on. * @param pageNumber the page number to get the results for. * @return a future containing the results of the requested page of applying the query. */ @Nonnull private CompletionStage<PagedQueryResult<T>> queryPage(final SphereClient client, final long pageNumber) { final QueryDsl<T, C> query = baseQuery .withOffset(pageNumber * pageSize) .withLimit(pageSize); return client.execute(query); }