org.epics.pvmanager
Class Aggregator<R,A>

java.lang.Object
  extended by org.epics.pvmanager.Function<R>
      extended by org.epics.pvmanager.Aggregator<R,A>
Type Parameters:
R - result type of aggregation
A - argument type being aggregated

public abstract class Aggregator<R,A>
extends Function<R>

Aggregates the data out of a Collector into a new data type.

The Aggregator uses calculate(java.util.List) to aggregate the values of the current time slice. If no values were collected in the current time slice, the last value (and only the last value, is passed so that the output remains consistent with what would be currently posted. Non calculation is done if no values were collected in the current and in the previous time slice.

Author:
carcassi

Constructor Summary
protected Aggregator(Function<java.util.List<A>> collector)
          Creates a new aggregator.
 
Method Summary
protected abstract  R calculate(java.util.List<A> data)
          Calculates the new value from a set of collected value.
 R getValue()
          Calculates, if needed, and then returns the value for this function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Aggregator

protected Aggregator(Function<java.util.List<A>> collector)
Creates a new aggregator. The given collector will be the source of data for the new aggregator.

Parameters:
collector - a suitable collector
Method Detail

getValue

public final R getValue()
Description copied from class: Function
Calculates, if needed, and then returns the value for this function.

Specified by:
getValue in class Function<R>
Returns:
a value

calculate

protected abstract R calculate(java.util.List<A> data)
Calculates the new value from a set of collected value. This function will never be called with an empty list

Parameters:
data - the new data to aggregate
Returns:
the aggregated value