Package com.azure.core.http.rest
Class PagedIterable<T>
java.lang.Object
com.azure.core.util.IterableStream<T>
com.azure.core.util.paging.ContinuablePagedIterable<String,T,P>
com.azure.core.http.rest.PagedIterableBase<T,PagedResponse<T>>
com.azure.core.http.rest.PagedIterable<T>
- Type Parameters:
T
- The type of value contained in thisIterableStream
.
- All Implemented Interfaces:
Iterable<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:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<S> PagedIterable<S>
Maps this PagedIterable instance of T to a PagedIterable instance of type S as per the provided mapper function.Methods inherited from class com.azure.core.util.paging.ContinuablePagedIterable
iterableByPage, iterableByPage, iterableByPage, iterableByPage, iterator, stream, streamByPage, streamByPage, streamByPage, streamByPage
Methods inherited from class com.azure.core.util.IterableStream
of
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PagedIterable
Creates instance givenPagedFlux
.- Parameters:
pagedFlux
- to use as iterable
-
-
Method Details
-
mapPage
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.
-