Package io.micronaut.core.util
Class StreamUtils
- java.lang.Object
-
- io.micronaut.core.util.StreamUtils
-
public class StreamUtils extends java.lang.Object
Utility methods for working with streams.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description StreamUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,A,D>
java.util.stream.Collector<T,?,D>maxAll(java.util.Comparator<? super T> comparator, java.util.stream.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>
java.util.stream.Collector<T,?,D>minAll(java.util.Comparator<? super T> comparator, java.util.stream.Collector<? super T,A,D> downstream)
A collector that returns all results that are the minimum based on the provided comparator.static <T> java.util.stream.Collector<T,java.util.Collection<T>,java.util.Collection<T>>
toImmutableCollection()
static <T,A extends java.util.Collection<T>>
java.util.stream.Collector<T,A,java.util.Collection<T>>toImmutableCollection(java.util.function.Supplier<A> collectionFactory)
-
-
-
Method Detail
-
maxAll
public static <T,A,D> java.util.stream.Collector<T,?,D> maxAll(java.util.Comparator<? super T> comparator, java.util.stream.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,D> java.util.stream.Collector<T,?,D> minAll(java.util.Comparator<? super T> comparator, java.util.stream.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 java.util.Collection<T>> java.util.stream.Collector<T,A,java.util.Collection<T>> toImmutableCollection(java.util.function.Supplier<A> collectionFactory)
- Type Parameters:
T
- The type of the input elementsA
- The accumulation type- Parameters:
collectionFactory
- The collection factory- Returns:
- An immutable collection
-
toImmutableCollection
public static <T> java.util.stream.Collector<T,java.util.Collection<T>,java.util.Collection<T>> toImmutableCollection()
- Type Parameters:
T
- The type- Returns:
- An immutable collection
-
-