IterableStream<T> Class
- java.
lang. Object - com.
azure. core. util. IterableStream<T>
- com.
Type Parameters
- T
The type of value in this Iterable.
Implements
public class IterableStream
implements Iterable<T>
This class provides utility to iterate over values using standard 'for-each' style loops or to convert them into a 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));
});
Constructor Summary
Constructor | Description |
---|---|
IterableStream(Iterable<T> iterable) |
Creates an instance with the given Iterable. |
IterableStream(Flux<T> flux) |
Creates an instance with the given Flux. |
Method Summary
Modifier and Type | Method and Description |
---|---|
static
Iterable |
of(Iterable<T> iterable)
Creates an IterableStream<T> from an Iterable. |
Iterator<T> |
iterator()
Utility function to provide Iterator of value |
Stream<T> |
stream()
Utility function to provide Stream of value |
Methods inherited from java.lang.Object
Constructor Details
IterableStream
public IterableStream(Iterable
Creates an instance with the given Iterable.
Parameters:
IterableStream
public IterableStream(Flux
Creates an instance with the given Flux.
Parameters:
Method Details
of
public static IterableStream
Creates an IterableStream<T> from an Iterable.
An empty IterableStream<T> will be returned if the input iterable is null
.
Parameters:
Returns:
iterator
public Iterator
Utility function to provide Iterator of value T
.
Returns:
T
.stream
public Stream
Utility function to provide Stream of value T
.
Returns:
T
.Applies to
Azure SDK for Java
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour