Class LambdaExpression
Encapsulates a parameterized ValueExpression
.
A LambdaExpression
is a representation of the EL Lambda
expression syntax. It consists of a list of the formal parameters and a
body, represented by a ValueExpression
.
The body can be any valid Expression
, including another
LambdaExpression
.
LambdaExpression
is created when an EL expression containing
a Lambda expression is evaluated.
A LambdaExpression
can be invoked by calling
invoke(javax.el.ELContext, java.lang.Object...)
, with
an ELContext
and a list of the actual arguments.
Alternately, a LambdaExpression
can be invoked without passing
a ELContext
, in which case the ELContext
previously
set by calling setELContext(javax.el.ELContext)
will be used.
The evaluation of the ValueExpression
in the body uses the
ELContext
to resolve references to the parameters, and to evaluate
the lambda expression.
The result of the evaluation is returned.
-
Constructor Summary
ConstructorDescriptionLambdaExpression
(List<String> formalParameters, ValueExpression expression) Creates a new LambdaExpression. -
Method Summary
Modifier and TypeMethodDescriptionInvoke the encapsulated Lambda expression.Invoke the encapsulated Lambda expression.void
setELContext
(ELContext context) Set the ELContext to use in evaluating the LambdaExpression.
-
Constructor Details
-
LambdaExpression
Creates a new LambdaExpression.- Parameters:
formalParameters
- The list of String representing the formal parameters.expression
- TheValueExpression
representing the body.
-
-
Method Details
-
setELContext
Set the ELContext to use in evaluating the LambdaExpression. The ELContext must to be set prior to the invocation of the LambdaExpression, unless it is supplied withinvoke(javax.el.ELContext, java.lang.Object...)
.- Parameters:
context
- The ELContext to use in evaluating the LambdaExpression.
-
invoke
Invoke the encapsulated Lambda expression.The supplied arguments are matched, in the same order, to the formal parameters. If there are more arguments than the formal parameters, the extra arguments are ignored. If there are less arguments than the formal parameters, an
ELException
is thrown.The actual Lambda arguments are added to the ELContext and are available during the evaluation of the Lambda expression. They are removed after the evaluation.
- Parameters:
elContext
- The ELContext used for the evaluation of the expression The ELContext set bysetELContext(javax.el.ELContext)
is ignored.args
- The arguments to invoke the Lambda expression. For calls with no arguments, an empty array must be provided. A Lambda argument can benull
.- Returns:
- The result of invoking the Lambda expression
- Throws:
ELException
- if not enough arguments are providedNullPointerException
- is elContext is null
-
invoke
Invoke the encapsulated Lambda expression.The supplied arguments are matched, in the same order, to the formal parameters. If there are more arguments than the formal parameters, the extra arguments are ignored. If there are less arguments than the formal parameters, an
ELException
is thrown.The actual Lambda arguments are added to the ELContext and are available during the evaluation of the Lambda expression. They are removed after the evaluation.
The ELContext set bysetELContext(javax.el.ELContext)
is used in the evaluation of the lambda Expression.- Parameters:
args
- The arguments to invoke the Lambda expression. For calls with no arguments, an empty array must be provided. A Lambda argument can benull
.- Returns:
- The result of invoking the Lambda expression
- Throws:
ELException
- if not enough arguments are provided
-