Class MapFunction
- java.lang.Object
-
- com.api.jsonata4java.expressions.functions.FunctionBase
-
- com.api.jsonata4java.expressions.functions.MapFunction
-
- All Implemented Interfaces:
Function,Serializable
public class MapFunction extends FunctionBase implements Function
From http://docs.jsonata.org/higher-order-functions#map Signature: $map(array, function) Returns an array containing the results of applying the function parameter to each value in the array parameter. The function that is supplied as the second parameter must have the following signature: function(value [, index [, array]]) Each value in the input array is passed in as the first parameter in the supplied function. The index (position) of that value in the input array is passed in as the second parameter, if specified. The whole input array is passed in as the third parameter, if specified. Examples $map([1..5], $string) results in ["1", "2", "3", "4", "5"] With user-defined (lambda) function: $map(Email.address, function($v, $i, $a) { 'Item ' & ($i+1) & ' of ' & $count($a) & ': ' & $v }) evaluates to: [ "Item 1 of 4: fred.smith@my-work.com", "Item 2 of 4: fsmith@my-work.com", "Item 3 of 4: freddy@my-social.com", "Item 4 of 4: frederic.smith@very-serious.com" ]- 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 MapFunction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObject(ExpressionsVisitor.SelectorArrayNode 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(ExpressionsVisitor.SelectorArrayNode result, com.fasterxml.jackson.databind.node.ObjectNode obj)
-
-