public class AvgGroupCalculator extends AbstractGroupCalculator<BigDecimal,AvgCalcIntermResult<BigDecimal>,Object>
Modifier and Type | Field and Description |
---|---|
static String |
LABEL
the label for this calculator
|
Constructor and Description |
---|
AvgGroupCalculator()
Default constructor (
label = "Average"
number of exact decimals = 32 )
|
AvgGroupCalculator(String label)
average group calculator constructor on which you can set the label
( number of exact decimal = 32)
|
AvgGroupCalculator(String label,
MathContext mathContext)
use this constructor if you want to control the number exact decimals
|
Modifier and Type | Method and Description |
---|---|
AvgCalcIntermResult<BigDecimal> |
compute(AvgCalcIntermResult<BigDecimal> intermResult,
Object newValue)
this compute method is based on the following formula:
AVG[n+1] = (n * AVG[n] + element[n+1] ) / (n+1)
|
AvgCalcIntermResult<BigDecimal> |
init()
init method required by the GroupCalculator
|
getLabel
public static final String LABEL
public AvgGroupCalculator()
public AvgGroupCalculator(String label)
label
- the label to be displayed on each totals rowpublic AvgGroupCalculator(String label, MathContext mathContext)
label
- the label to be displayed on each total rowmathContext
- the math context for BigDecimal operationspublic AvgCalcIntermResult<BigDecimal> init()
public AvgCalcIntermResult<BigDecimal> compute(AvgCalcIntermResult<BigDecimal> intermResult, Object newValue)
intermResult
- the previous intermediate result ( it's the 10 in my example)newValue
- the current value (it's the "whatever text" in my example above)Copyright © 2006–2015. All rights reserved.