ehcache

net.sf.ehcache.search.aggregator
Class Average

java.lang.Object
  extended by net.sf.ehcache.search.aggregator.Average
All Implemented Interfaces:
AggregatorInstance<Double>

public class Average
extends Object
implements AggregatorInstance<Double>

Compute the average (arithmetic mean) as a double

Author:
teck

Constructor Summary
Average(Attribute<?> attribute)
           
 
Method Summary
 void accept(Object input)
          Add the given value to the aggregator function
 Number aggregateResult()
          Retrieve the final result
 Average 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

Average

public Average(Attribute<?> attribute)
Parameters:
attribute -
Method Detail

createClone

public Average createClone()
Create a clone of this aggregator, detaching from its result

Specified by:
createClone in interface AggregatorInstance<Double>
Returns:

accept

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

NOTE: Null values are ignored and not included in the computation

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

aggregateResult

public Number aggregateResult()
Retrieve the final result

NOTE: null is returned if there was no input supplied to this function

Specified by:
aggregateResult in interface AggregatorInstance<Double>
Returns:
aggregate result

getAttribute

public Attribute getAttribute()
Get the attribute to pass to aggregator

Specified by:
getAttribute in interface AggregatorInstance<Double>
Returns:
attribute to aggregate (null if no attribute is applicable to function)

ehcache

Copyright 2001-2017, Terracotta, Inc.