Package io.micronaut.core.util
Class StreamUtils
java.lang.Object
io.micronaut.core.util.StreamUtils
Utility methods for working with streams.
- Since:
- 1.0
- Author:
- James Kleeh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,A, D> Collector<T, ?, D> maxAll(Comparator<? super T> comparator, Collector<? super T, A, D> downstream) A collector that returns all results that are the maximum based on the provided comparator.static <T,A, D> Collector<T, ?, D> minAll(Comparator<? super T> comparator, Collector<? super T, A, D> downstream) A collector that returns all results that are the minimum based on the provided comparator.static <T,A extends Collection<T>>
Collector<T,A, Collection<T>> toImmutableCollection(Supplier<A> collectionFactory)
-
Constructor Details
-
StreamUtils
public StreamUtils()
-
-
Method Details
-
maxAll
public static <T,A, Collector<T,D> ?, maxAllD> (Comparator<? super T> comparator, Collector<? super T, A, D> downstream) A collector that returns all results that are the maximum based on the provided comparator.- Type Parameters:
T- The type of objects being streamedA- The mutable accumulation type of the reduction operationD- The result type of the reduction operation- Parameters:
comparator- The comparator to order the items in the streamdownstream- Which collector to use to combine the results- Returns:
- A new collector to provide the desired result
-
minAll
public static <T,A, Collector<T,D> ?, minAllD> (Comparator<? super T> comparator, Collector<? super T, A, D> downstream) A collector that returns all results that are the minimum based on the provided comparator.- Type Parameters:
T- The type of objects being streamedA- The mutable accumulation type of the reduction operationD- The result type of the reduction operation- Parameters:
comparator- The comparator to order the items in the streamdownstream- Which collector to use to combine the results- Returns:
- A new collector to provide the desired result
-
toImmutableCollection
public static <T,A extends Collection<T>> Collector<T,A, toImmutableCollectionCollection<T>> (Supplier<A> collectionFactory) - Type Parameters:
T- The type of the input elementsA- The accumulation type- Parameters:
collectionFactory- The collection factory- Returns:
- An immutable collection
-