Class Agg.OrderedValue<T>

  • Direct Known Subclasses:
    Agg.Max, Agg.Min
    Enclosing class:
    Agg

    public static class Agg.OrderedValue<T>
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Comparator<? super T> comparator  
      protected T value  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected OrderedValue​(java.util.Comparator<? super T> comparator, T initialValue)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean apply​(T newValue)
      Null-safe apply a new value, calculate the agg (e.g.
      boolean apply​(T newValue, boolean includeNulls)
      Apply a new value, calculate the agg, and returns the new value.
      void clear()
      Clears the current value by setting it to null.
      T get()
      Gets the current value.
      boolean isAbsent()  
      boolean isPresent()  
      Maybe<T> maybe()  
      void set​(T value)
      Directly sets the current value.
      • Methods inherited from class java.lang.Object

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

      • comparator

        protected final java.util.Comparator<? super T> comparator
      • value

        protected T value
    • Constructor Detail

      • OrderedValue

        protected OrderedValue​(java.util.Comparator<? super T> comparator,
                               T initialValue)
    • Method Detail

      • isAbsent

        public boolean isAbsent()
      • isPresent

        public boolean isPresent()
      • maybe

        public Maybe<T> maybe()
      • clear

        public void clear()
        Clears the current value by setting it to null.
      • set

        public void set​(T value)
        Directly sets the current value.
        Parameters:
        value -
      • get

        public T get()
        Gets the current value.
        Returns:
      • apply

        public boolean apply​(T newValue)
        Null-safe apply a new value, calculate the agg (e.g. min or max), and returns the new value. Nulls are skipped for evaluation!
        Parameters:
        newValue -
        Returns:
        True if modified, otherwise false.
      • apply

        public boolean apply​(T newValue,
                             boolean includeNulls)
        Apply a new value, calculate the agg, and returns the new value. If you do includeNull, you MUST provide a null-safe comparator otherwise you will get a runtime NullPointerException.
        Parameters:
        newValue -
        includeNulls -
        Returns:
        True if modified, otherwise false.