Class PagedIterable<T>

  • Type Parameters:
    T - The type of value contained in this IterableStream.
    All Implemented Interfaces:
    Iterable<T>

    public class PagedIterable<T>
    extends PagedIterableBase<T,​PagedResponse<T>>
    This class provides utility to iterate over PagedResponse using Stream and Iterable interfaces.

    Code sample using Stream by page

     // process the streamByPage
     pagedIterableResponse.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 %d %n", value));
     });
    
     

    Code sample using Iterable by page

     // process the iterableByPage
     pagedIterableResponse.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 %d %n", value));
     });
     

    Code sample using Iterable by page and while loop

     // iterate over each page
     for (PagedResponse<Integer> resp : pagedIterableResponse.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 %d %n", value));
     }
     
    See Also:
    PagedResponse, IterableStream
    • Constructor Detail

      • PagedIterable

        public PagedIterable​(PagedFlux<T> pagedFlux)
        Creates instance given PagedFlux.
        Parameters:
        pagedFlux - to use as iterable
    • Method Detail

      • mapPage

        public <S> PagedIterable<S> mapPage​(Function<T,​S> mapper)
        Maps this PagedIterable instance of T to a PagedIterable instance of type S as per the provided mapper function.
        Type Parameters:
        S - The mapped type.
        Parameters:
        mapper - The mapper function to convert from type T to type S.
        Returns:
        A PagedIterable of type S.