T - The type of value in this Iterable.public class IterableStream<T> extends Object implements Iterable<T>
Stream and operate in that fashion.
Code sample using Stream
// process the stream
myIterableStream.stream().forEach(resp -> {
if (resp.getStatusCode() == HttpURLConnection.HTTP_OK) {
System.out.printf("Response headers are %s. Url %s%n", resp.getDeserializedHeaders(),
resp.getRequest().getUrl());
resp.getElements().forEach(value -> System.out.printf("Response value is %d%n", value));
}
});
Code sample using Iterator
// Iterate over iterator
for (PagedResponseBase<String, Integer> resp : myIterableStream) {
if (resp.getStatusCode() == HttpURLConnection.HTTP_OK) {
System.out.printf("Response headers are %s. Url %s%n", resp.getDeserializedHeaders(),
resp.getRequest().getUrl());
resp.getElements().forEach(value -> System.out.printf("Response value is %d%n", value));
}
}
Code sample using Stream and filter
// process the stream
myIterableStream.stream().filter(resp -> resp.getStatusCode() == HttpURLConnection.HTTP_OK)
.limit(10)
.forEach(resp -> {
System.out.printf("Response headers are %s. Url %s%n", resp.getDeserializedHeaders(),
resp.getRequest().getUrl());
resp.getElements().forEach(value -> System.out.printf("Response value is %d%n", value));
});
Iterable| Constructor and Description |
|---|
IterableStream(Flux<T> flux)
Creates an instance with the given
Flux. |
IterableStream(Iterable<T> iterable)
Creates an instance with the given
Iterable. |
| Modifier and Type | Method and Description |
|---|---|
Iterator<T> |
iterator()
Utility function to provide
Iterator of value T. |
static <T> IterableStream<T> |
of(Iterable<T> iterable)
Creates an
IterableStream from an Iterable. |
Stream<T> |
stream()
Utility function to provide
Stream of value T. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic IterableStream(Flux<T> flux)
Flux.flux - Flux of items to iterate over.NullPointerException - If flux is null.public IterableStream(Iterable<T> iterable)
Iterable.iterable - Collection of items to iterate over.NullPointerException - If iterable is null.public Stream<T> stream()
Stream of value T.Stream of value T.public static <T> IterableStream<T> of(Iterable<T> iterable)
IterableStream from an Iterable.
An empty IterableStream will be returned if the input iterable is null.
T - The type of value in this Iterable.iterable - Collection of items to iterate over.IterableStream based on the passed collection.Copyright © 2021 Microsoft Corporation. All rights reserved.