public final class AverageAccumulator extends Accumulator
getResult
method variants.Modifier and Type | Class and Description |
---|---|
private class |
AverageAccumulator.Data
A
DataBundle implementation which keeps a running total of
a numeric value and an iteration count, and provides the average value
when requested. |
Accumulator.DataBundle
Modifier and Type | Field and Description |
---|---|
(package private) static int |
WEIGHT
Relative weight of this accumulator type for sorting purposes
|
BASE_WEIGHT
Constructor and Description |
---|
AverageAccumulator(BaseDataType variable)
Constructor which stores a mutable variable reference as the
accumulator's data source.
|
AverageAccumulator(java.lang.Class<? extends BaseDataType> cls)
Constructor which stores no data source.
|
AverageAccumulator(double value)
Create an instance which accumulates an decimal constant upon each loop
iteration.
|
AverageAccumulator(int value)
Create an instance which accumulates an integral constant upon each loop
iteration.
|
AverageAccumulator(Resolvable dataSource)
Constructor which stores a
Resolvable as the accumulator's
data source. |
AverageAccumulator(Resolvable dataSource,
boolean register)
Constructor which stores a
Resolvable as the accumulator's
data source. |
Modifier and Type | Method and Description |
---|---|
protected Accumulator.DataBundle |
createDataBundle()
Create a data bundle which understands how to calculate an average.
|
BaseDataType |
getFullResult()
Get the full result of all accumulations so far for this accumulator,
across all break groups.
|
java.lang.String |
getLabel()
Get the label associated with this accumulator type, for use in the UI.
|
decimal |
getResult()
Get the numeric average of all instances of the accumulated data source
across all iterations of the loop.
|
decimal |
getResult(Resolvable breakGroupKey)
Get the numeric average of all instances of the accumulated data source
across all iterations of the specified break group.
|
BaseDataType |
getSubResult()
Get the current subgroup result for the first registered break group in
this accumulator.
|
int |
getWeight()
Get the relative weight associated with this accumulator type, for use
in sorting accumulator instances of different types according to their
natural display order.
|
accumulate, accumulate, addBreakGroup, assign, breakGroupKeys, calculate, createUnknown, deepCopy, deleted, finished, getDataSource, getFirstBreakGroupKey, getType, ifEnded, isLastOfGroup, isSubgroupOnly, isSubOnly, isUndoable, isUninitialized, iterate, iterate, iterate, postponeReset, postponeUnknown, reset, resetData, retry, scopeDeleted, scopeFinished, scopeStart, setLastOfGroup, setSubgroupOnly, setSubOnly
changed, checkUndoable, checkUndoable, checkUndoable, getTransLevel, isGlobal, markUndoable, popBlock, rollback, setGlobal
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initFailure
static final int WEIGHT
public AverageAccumulator(java.lang.Class<? extends BaseDataType> cls)
accumulate
method. The accumulator is registered with the AccumulatorManager and
the TransactionManager in the next scope.cls
- Data type of the value being accumulated.public AverageAccumulator(int value)
value
- Constant which will be accumulated at each iteration.public AverageAccumulator(double value)
value
- Constant which will be accumulated at each iteration.public AverageAccumulator(BaseDataType variable)
variable
- Mutable variable from which data is collected.public AverageAccumulator(Resolvable dataSource)
Resolvable
as the accumulator's
data source. When an iteration occurs, the accumulator gathers its data
by resolving the current value of the data source.
The accumulator will be automatically registered at the NEXT scope that is opened. This is perfect for use in class members that are initialized in an initializer which occurs before the scope is open.
dataSource
- Data source from which data is collected.public AverageAccumulator(Resolvable dataSource, boolean register)
Resolvable
as the accumulator's
data source. When an iteration occurs, the accumulator gathers its data
by resolving the current value of the data source. The accumulator is
registered with the AccumulatorManager and the TransactionManager, in the next scope.dataSource
- Data source from which data is collected.register
- This flag will be false
only if a copy object is instantiated.
Because we use the copy only for roll-back purposes, we do not need to add it to
the TransactionManager or AccumulatorManager.public BaseDataType getFullResult()
getFullResult
in class Accumulator
public BaseDataType getSubResult()
getSubResult
in class Accumulator
null
if no subgroups are being tracked by this
accumulator.public java.lang.String getLabel()
getLabel
in class Accumulator
public int getWeight()
getWeight
in class Accumulator
public decimal getResult()
public decimal getResult(Resolvable breakGroupKey)
breakGroupKey
- Key identifying the break group for which the data is desired.protected Accumulator.DataBundle createDataBundle()
createDataBundle
in class Accumulator
AverageAccumulator.Data
.