Class 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 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