- java.lang.Object
-
- javax.el.LambdaExpression
-
public class LambdaExpression extends Object
Encapsulates a parameterized
ValueExpression
.A
ALambdaExpression
is a representation of the EL Lambda expression syntax. It consists of a list of the formal parameters and a body, represented by aValueExpression
. The body can be any validExpression
, including anotherLambdaExpression
.LambdaExpression
is created when an EL expression containing a Lambda expression is evaluated.A
LambdaExpression
can be invoked by callinginvoke(javax.el.ELContext, java.lang.Object...)
, with anELContext
and a list of the actual arguments. Alternately, aLambdaExpression
can be invoked without passing aELContext
, in which case theELContext
previously set by callingsetELContext(javax.el.ELContext)
will be used. The evaluation of theValueExpression
in the body uses theELContext
to resolve references to the parameters, and to evaluate the lambda expression. The result of the evaluation is returned.
-
-
Constructor Summary
Constructors Constructor and Description LambdaExpression(List<String> formalParameters, ValueExpression expression)
Creates a new LambdaExpression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Object
invoke(ELContext elContext, Object... args)
Invoke the encapsulated Lambda expression.Object
invoke(Object... args)
Invoke the encapsulated Lambda expression.void
setELContext(ELContext context)
Set the ELContext to use in evaluating the LambdaExpression.
-
-
-
Constructor Detail
-
LambdaExpression
public LambdaExpression(List<String> formalParameters, ValueExpression expression)
Creates a new LambdaExpression.- Parameters:
formalParameters
- The list of String representing the formal parameters.expression
- TheValueExpression
representing the body.
-
-
Method Detail
-
setELContext
public void setELContext(ELContext context)
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
public Object invoke(ELContext elContext, Object... args) throws ELException
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
public Object invoke(Object... args)
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
-
-
Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/el/lambdaexpression.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.