Package com.azure.core.http.rest
Class PagedIterableBase<T,P extends PagedResponse<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,P>
- Type Parameters:
T- The type of value contained in thisIterableStream.P- The response extending fromPagedResponse
- All Implemented Interfaces:
Iterable<T>
- Direct Known Subclasses:
AutocompletePagedIterable,PagedIterable,SearchPagedIterable,SuggestPagedIterable
public class PagedIterableBase<T,P extends PagedResponse<T>>
extends ContinuablePagedIterable<String,T,P>
This class provides utility to iterate over responses that extend
PagedResponse 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));
}
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPagedIterableBase(PagedFluxBase<T, P> pagedFluxBase) Creates instance givenPagedFluxBase. -
Method Summary
Methods inherited from class com.azure.core.util.paging.ContinuablePagedIterable
iterableByPage, iterableByPage, iterableByPage, iterableByPage, iterator, stream, streamByPage, streamByPage, streamByPage, streamByPageMethods inherited from class com.azure.core.util.IterableStream
ofMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PagedIterableBase
Creates instance givenPagedFluxBase.- Parameters:
pagedFluxBase- to use as iterable
-