Class ReduceFunction
- java.lang.Object
-
- com.api.jsonata4java.expressions.functions.FunctionBase
-
- com.api.jsonata4java.expressions.functions.ReduceFunction
-
- All Implemented Interfaces:
Function,Serializable
public class ReduceFunction extends FunctionBase implements Function
From http://docs.jsonata.org/higher-order-functions#reduce Signature: $reduce(array, function [, init]) Returns an aggregated value derived from applying the function parameter successively to each value in array in combination with the result of the previous application of the function. The function must accept at least two arguments, and behaves like an infix operator between each value within the array. The signature of this supplied function must be of the form: myfunc($accumulator, $value[, $index[, $array]]) Example ( $product := function($i, $j){$i * $j}; $reduce([1..5], $product) ) This multiplies all the values together in the array [1..5] to return 120. If the optional init parameter is supplied, then that value is used as the initial value in the aggregation (fold) process. If not supplied, the initial value is the first value in the array parameter.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringERR_ARG1_MUST_BE_ARRAY_OF_OBJECTSstatic StringERR_ARG1BADTYPEstatic StringERR_ARG2BADTYPEstatic StringERR_BAD_CONTEXT
-
Constructor Summary
Constructors Constructor Description ReduceFunction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObject(com.fasterxml.jackson.databind.node.ArrayNode result, com.fasterxml.jackson.databind.node.ObjectNode obj)intgetMaxArgs()intgetMinArgs()StringgetSignature()com.fasterxml.jackson.databind.JsonNodeinvoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx)-
Methods inherited from class com.api.jsonata4java.expressions.functions.FunctionBase
getArgumentCount, getFunctionName
-
-
-
-
Method Detail
-
invoke
public com.fasterxml.jackson.databind.JsonNode invoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx)
-
getMaxArgs
public int getMaxArgs()
- Specified by:
getMaxArgsin interfaceFunction
-
getMinArgs
public int getMinArgs()
- Specified by:
getMinArgsin interfaceFunction
-
getSignature
public String getSignature()
- Specified by:
getSignaturein interfaceFunction
-
addObject
public void addObject(com.fasterxml.jackson.databind.node.ArrayNode result, com.fasterxml.jackson.databind.node.ObjectNode obj)
-
-