Package org.ethelred.util.stream
Class SummaryStatistics<T>
- java.lang.Object
-
- org.ethelred.util.stream.SummaryStatistics<T>
-
@NullMarked public class SummaryStatistics<T> extends Object
A stream Collector that captures basic statistics in a single result. Currently, count, max and min.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <A extends Comparable<? super A>>
Collector<A,?,SummaryStatistics<A>>collector()A Collector that uses the natural order to determine max and min.static <B> Collector<B,?,SummaryStatistics<B>>collector(Comparator<B> comparator)A Collector that uses an explicit Comparator to determine max and min.intgetCount()Optional<T>getMax()Optional<T>getMin()
-
-
-
Method Detail
-
collector
public static <A extends Comparable<? super A>> Collector<A,?,SummaryStatistics<A>> collector()
A Collector that uses the natural order to determine max and min.- Type Parameters:
A- The type of elements in the Stream- Returns:
- Collector producing SummaryStatistics.
-
collector
public static <B> Collector<B,?,SummaryStatistics<B>> collector(Comparator<B> comparator)
A Collector that uses an explicit Comparator to determine max and min.- Type Parameters:
B- The type of elements in the Stream- Parameters:
comparator- Ordering to use- Returns:
- Collector producing SummaryStatistics.
-
getMin
public Optional<T> getMin()
- Returns:
- The minimum valued element from the Stream. Empty if the Stream was empty.
-
getMax
public Optional<T> getMax()
- Returns:
- The maximum valued element from the Stream. Empty if the Stream was empty.
-
getCount
public int getCount()
- Returns:
- Count of elements from the Stream
-
-