public class LambdaExpression
extends java.lang.Object
ValueExpression
.
A LambdaExpression
is a representation of the Jakarta Expression Language 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
.
A LambdaExpression
is created when an Jakarta Expression Language expression containing a Lambda
expression is evaluated.
A LambdaExpression
can be invoked by calling invoke(jakarta.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(jakarta.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 and Description |
---|
LambdaExpression(java.util.List<java.lang.String> formalParameters,
ValueExpression expression)
Creates a new LambdaExpression.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
invoke(ELContext elContext,
java.lang.Object... args)
Invoke the encapsulated Lambda expression.
|
java.lang.Object |
invoke(java.lang.Object... args)
Invoke the encapsulated Lambda expression.
|
void |
setELContext(ELContext context)
Set the ELContext to use in evaluating the LambdaExpression.
|
public LambdaExpression(java.util.List<java.lang.String> formalParameters, ValueExpression expression)
formalParameters
- The list of String representing the formal parameters.expression
- The ValueExpression
representing the body.public void setELContext(ELContext context)
invoke(jakarta.el.ELContext, java.lang.Object...)
.context
- The ELContext to use in evaluating the LambdaExpression.public java.lang.Object invoke(ELContext elContext, java.lang.Object... args) throws ELException
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.
elContext
- The ELContext used for the evaluation of the expression The ELContext set by setELContext(jakarta.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 be null
.ELException
- if not enough arguments are providedjava.lang.NullPointerException
- is elContext is nullpublic java.lang.Object invoke(java.lang.Object... args)
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(jakarta.el.ELContext)
is used in the evaluation of the lambda Expression.args
- The arguments to invoke the Lambda expression. For calls with no arguments, an empty array must be
provided. A Lambda argument can be null
.ELException
- if not enough arguments are provided