public class GroupSum<T> extends Object
The sum function for calculation a group sum takes two arguments: the collection as JEXL expression (or its name as a String) and the name (as String) of the attribute. The attribute can be a object property or a Map entry. The value type T can be of any type and is implemented by a generic SummarizerBuilder.
Call setTransformationConfig() if you want to use the methods with filter condition parameter.
Add an instance of this class e.g. with name "G" to your Context.
${G.sum("salary", employees.items)}
Above the 2nd argument is a JEXL expression. The collection name as String is also possible:
${G.sum("salary", "employees.items")}
Constructor and Description |
---|
GroupSum(Context context,
SummarizerBuilder<T> sumBuilder) |
Modifier and Type | Method and Description |
---|---|
String |
getObjectVarName() |
TransformationConfig |
getTransformationConfig() |
void |
setObjectVarName(String objectVarName) |
void |
setTransformationConfig(TransformationConfig transformationConfig) |
T |
sum(String fieldName,
Collection<Object> collection)
Returns the sum of the given field of all items.
|
T |
sum(String fieldName,
Collection<Object> collection,
String filter) |
T |
sum(String fieldName,
String expression)
Returns the sum of the given field of all items.
|
T |
sum(String fieldName,
String expression,
String filter) |
public GroupSum(Context context, SummarizerBuilder<T> sumBuilder)
public T sum(String fieldName, String expression)
fieldName
- name of the field of type T to be summed (without the loop var name!)expression
- JEXL expression as String, usually name of the Collection, often ends with ".items"public T sum(String fieldName, Collection<Object> collection)
fieldName
- name of the field of type T to be summed (without the loop var name!)collection
- the collection; inside Excel file it's a JEXL expressionpublic TransformationConfig getTransformationConfig()
public void setTransformationConfig(TransformationConfig transformationConfig)
public String getObjectVarName()
public void setObjectVarName(String objectVarName)
public T sum(String fieldName, Collection<Object> collection, String filter)
Copyright © 2023. All rights reserved.