public final class CollectorUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T,Y extends java.lang.Comparable<Y>> |
maxBy(java.util.function.Function<T,Y> projection)
Find the item for which the supplied projection returns the maximum value.
|
static <T,Y> java.util.stream.Collector<T,?,java.util.Optional<T>> |
maxBy(java.util.function.Function<T,Y> projection,
java.util.Comparator<Y> comparator)
Find the item for which the supplied projection returns the maximum value (variant for non-naturally-comparable
projected values).
|
static <T,Y extends java.lang.Comparable<Y>> |
minBy(java.util.function.Function<T,Y> projection)
Find the item for which the supplied projection returns the minimum value.
|
static <T,Y> java.util.stream.Collector<T,?,java.util.Optional<T>> |
minBy(java.util.function.Function<T,Y> projection,
java.util.Comparator<Y> comparator)
Find the item for which the supplied projection returns the minimum value (variant for non-naturally-comparable
projected values).
|
static <T> java.util.function.BinaryOperator<T> |
noCombiner()
A combiner for all the cases when you don't intend to reduce/collect on a parallel stream.
|
static <T> java.util.stream.Collector<T,java.util.concurrent.atomic.AtomicReference<T>,java.util.Optional<T>> |
unique()
A collector that returns the single member of a stream (if present), or throws a
NonUniqueValueException if more
than one item is found. |
public static <T,Y extends java.lang.Comparable<Y>> java.util.stream.Collector<T,?,java.util.Optional<T>> maxBy(java.util.function.Function<T,Y> projection)
T - The type of each item.Y - The type of the projected value to compare on.projection - The projection to apply to each item.public static <T,Y> java.util.stream.Collector<T,?,java.util.Optional<T>> maxBy(java.util.function.Function<T,Y> projection,
java.util.Comparator<Y> comparator)
T - The type of each item.Y - The type of the projected value to compare on.projection - The projection to apply to each item.comparator - The comparator to use to compare the projected values.public static <T,Y extends java.lang.Comparable<Y>> java.util.stream.Collector<T,?,java.util.Optional<T>> minBy(java.util.function.Function<T,Y> projection)
T - The type of each item.Y - The type of the projected value to compare on.projection - The projection to apply to each item.public static <T,Y> java.util.stream.Collector<T,?,java.util.Optional<T>> minBy(java.util.function.Function<T,Y> projection,
java.util.Comparator<Y> comparator)
T - The type of each item.Y - The type of the projected value to compare on.projection - The projection to apply to each item.comparator - The comparator to use to compare the projected values.public static <T> java.util.stream.Collector<T,java.util.concurrent.atomic.AtomicReference<T>,java.util.Optional<T>> unique()
NonUniqueValueException if more
than one item is found.T - The type of the items in the stream.public static <T> java.util.function.BinaryOperator<T> noCombiner()
IllegalStateException if it is ever called.T - The type of partial result you don't intend to combine.Copyright © 2015. All Rights Reserved.