PagedIterableBase<T,P> Class

Type Parameters

T

The type of value contained in this IterableStream.

P

The response extending from PagedResponse

public class PagedIterableBase<T,P>
extends ContinuablePagedIterable<String,T,P>

This class provides utility to iterate over responses that extend PagedResponse<T> using Stream and Iterable interfaces.

Code sample using Stream by page

// process the streamByPage
 CustomPagedFlux<String> customPagedFlux = createCustomInstance();
 PagedIterableBase<String, PagedResponse<String>> customPagedIterableResponse =
     new PagedIterableBase<>(customPagedFlux);
 customPagedIterableResponse.streamByPage().forEach(resp -> {
     System.out.printf("Response headers are %s. Url %s  and status code %d %n", resp.getHeaders(),
         resp.getRequest().getUrl(), resp.getStatusCode());
     resp.getElements().forEach(value -> System.out.printf("Response value is %s %n", value));
 });

Code sample using Iterable by page

// process the iterableByPage
 customPagedIterableResponse.iterableByPage().forEach(resp -> {
     System.out.printf("Response headers are %s. Url %s  and status code %d %n", resp.getHeaders(),
         resp.getRequest().getUrl(), resp.getStatusCode());
     resp.getElements().forEach(value -> System.out.printf("Response value is %s %n", value));
 });

Code sample using Iterable by page and while loop

// iterate over each page
 for (PagedResponse<String> resp : customPagedIterableResponse.iterableByPage()) {
     System.out.printf("Response headers are %s. Url %s  and status code %d %n", resp.getHeaders(),
         resp.getRequest().getUrl(), resp.getStatusCode());
     resp.getElements().forEach(value -> System.out.printf("Response value is %s %n", value));
 }

Constructor Summary

Constructor Description
PagedIterableBase(PagedFluxBase<T,P> pagedFluxBase)

Creates instance given PagedFluxBase<T,P>.

PagedIterableBase(Supplier<PageRetrieverSync<String,P>> provider)

Creates instance given the PageRetrieverSync<C,P> Supplier.

Methods inherited from IterableStream

Methods inherited from ContinuablePagedIterable

Methods inherited from java.lang.Object

Constructor Details

PagedIterableBase

public PagedIterableBase(PagedFluxBase pagedFluxBase)

Creates instance given PagedFluxBase<T,P>.

Parameters:

pagedFluxBase - to use as iterable

PagedIterableBase

public PagedIterableBase(Supplier> provider)

Creates instance given the PageRetrieverSync<C,P> Supplier.

Parameters:

provider - The page retriever Supplier.

Applies to