Class Sum

  • All Implemented Interfaces:
    AggregatorInstance<java.lang.Long>

    public class Sum
    extends java.lang.Object
    implements AggregatorInstance<java.lang.Long>
    Sums the results

    Sum can be used with most numeric types

    Author:
    Greg Luck
    • Constructor Summary

      Constructors 
      Constructor Description
      Sum​(Attribute<?> attribute)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(java.lang.Object input)
      Add the given value to the aggregator function
      java.lang.Number aggregateResult()
      Retrieve the final result
      Sum createClone()
      Create a clone of this aggregator, detaching from its result
      Attribute getAttribute()
      Get the attribute to pass to aggregator
      • Methods inherited from class java.lang.Object

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

      • Sum

        public Sum​(Attribute<?> attribute)
        Parameters:
        attribute -
    • Method Detail

      • createClone

        public Sum createClone()
        Create a clone of this aggregator, detaching from its result
        Specified by:
        createClone in interface AggregatorInstance<java.lang.Long>
        Returns:
      • accept

        public void accept​(java.lang.Object input)
                    throws AggregatorException
        Add the given value to the aggregator function

        NOTE: null inputs are ignored

        Specified by:
        accept in interface AggregatorInstance<java.lang.Long>
        Parameters:
        input - a single input value
        Throws:
        AggregatorException - if the function cannot be computed, possibly due to unsupported types
      • aggregateResult

        public java.lang.Number aggregateResult()
        Retrieve the final result

        NOTE: May return null if no input supplied

        Specified by:
        aggregateResult in interface AggregatorInstance<java.lang.Long>
        Returns:
        aggregate result
      • getAttribute

        public Attribute getAttribute()
        Get the attribute to pass to aggregator
        Specified by:
        getAttribute in interface AggregatorInstance<java.lang.Long>
        Returns:
        attribute to aggregate (null if no attribute is applicable to function)