org.springframework.expression.spel.ast
Class FunctionReference
java.lang.Object
org.springframework.expression.spel.ast.SpelNodeImpl
org.springframework.expression.spel.ast.FunctionReference
- All Implemented Interfaces:
- SpelNode
public class FunctionReference
- extends SpelNodeImpl
A function reference is of the form "#someFunction(a,b,c)". Functions may be defined in the context prior to the
expression being evaluated or within the expression itself using a lambda function definition. For example: Lambda
function definition in an expression: "(#max = {|x,y|$x>$y?$x:$y};max(2,3))" Calling context defined function:
"#isEven(37)". Functions may also be static java methods, registered in the context prior to invocation of the
expression.
Functions are very simplistic, the arguments are not part of the definition (right now),
so the names must be unique.
- Since:
- 3.0
- Author:
- Andy Clement
Field Summary |
private java.lang.String |
name
|
Methods inherited from class org.springframework.expression.spel.ast.SpelNodeImpl |
getChild, getChildCount, getEndPosition, getObjectClass, getPreviousChild, getStartPosition, getTypedValue, getValue, getValue, isWritable, nextChildIs, setValue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
name
private final java.lang.String name
FunctionReference
public FunctionReference(java.lang.String functionName,
int pos,
SpelNodeImpl... arguments)
getValueInternal
public TypedValue getValueInternal(ExpressionState state)
throws EvaluationException
- Specified by:
getValueInternal
in class SpelNodeImpl
- Throws:
EvaluationException
executeFunctionJLRMethod
private TypedValue executeFunctionJLRMethod(ExpressionState state,
java.lang.reflect.Method method)
throws EvaluationException
- Execute a function represented as a java.lang.reflect.Method.
- Parameters:
state
- the expression evaluation statethe
- java method to invoke
- Returns:
- the return value of the invoked Java method
- Throws:
EvaluationException
- if there is any problem invoking the method
toStringAST
public java.lang.String toStringAST()
- Specified by:
toStringAST
in interface SpelNode
- Specified by:
toStringAST
in class SpelNodeImpl
- Returns:
- the string form of this AST node
getArguments
private java.lang.Object[] getArguments(ExpressionState state)
throws EvaluationException
- Compute the arguments to the function, they are the children of this expression node.
- Returns:
- an array of argument values for the function call
- Throws:
EvaluationException