Class SummaryStatistics<T>


  • @NullMarked
    public class SummaryStatistics<T>
    extends java.lang.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 java.lang.Comparable<? super A>>
      java.util.stream.Collector<A,​?,​SummaryStatistics<A>>
      collector()
      A Collector that uses the natural order to determine max and min.
      static <B> java.util.stream.Collector<B,​?,​SummaryStatistics<B>> collector​(java.util.Comparator<B> comparator)
      A Collector that uses an explicit Comparator to determine max and min.
      int getCount()  
      java.util.Optional<T> getMax()  
      java.util.Optional<T> getMin()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • collector

        public static <A extends java.lang.Comparable<? super A>> java.util.stream.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> java.util.stream.Collector<B,​?,​SummaryStatistics<B>> collector​(java.util.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 java.util.Optional<T> getMin()
        Returns:
        The minimum valued element from the Stream. Empty if the Stream was empty.
      • getMax

        public java.util.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