Class ReduceFunction
- java.lang.Object
-
- com.api.jsonata4java.expressions.functions.FunctionBase
-
- com.api.jsonata4java.expressions.functions.ReduceFunction
-
public class ReduceFunction extends FunctionBase
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.api.jsonata4java.expressions.functions.FunctionBase
FunctionBase.CtxEvalResult
-
-
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
evalContext, getArgumentCount, getFunctionName
-
-
-
-
Method Detail
-
invoke
public com.fasterxml.jackson.databind.JsonNode invoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx)
- Specified by:
invokein classFunctionBase
-
getMaxArgs
public int getMaxArgs()
- Specified by:
getMaxArgsin classFunctionBase
-
getMinArgs
public int getMinArgs()
- Specified by:
getMinArgsin classFunctionBase
-
getSignature
public String getSignature()
- Specified by:
getSignaturein classFunctionBase
-
addObject
public void addObject(com.fasterxml.jackson.databind.node.ArrayNode result, com.fasterxml.jackson.databind.node.ObjectNode obj)
-
-