Class LambdaExpression
java.lang.Object
jakarta.el.LambdaExpression
Represents a lambda expression in EL. A lambda expression has a list of formal parameters
and a body expression. When invoked, the lambda binds the actual arguments to its formal
parameters and evaluates the body expression within a scoped
ELContext. Lambda
expressions support nesting, with inner lambdas having access to outer lambda arguments.- Since:
- EL 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionLambdaExpression(List<String> formalParameters, ValueExpression expression) Constructs a LambdaExpression with the given formal parameters and body expression. -
Method Summary
Modifier and TypeMethodDescriptionInvokes the lambda expression with the given arguments in the specified EL context.Invokes the lambda expression with the given arguments using the EL context set bysetELContext(ELContext).voidsetELContext(ELContext context) Sets theELContextto be used when this lambda is invoked without an explicit context argument.
-
Constructor Details
-
LambdaExpression
Constructs a LambdaExpression with the given formal parameters and body expression.- Parameters:
formalParameters- the list of formal parameter names for the lambdaexpression- the body expression to evaluate when the lambda is invoked
-
-
Method Details
-
setELContext
-
invoke
Invokes the lambda expression with the given arguments in the specified EL context. The formal parameters are bound to the corresponding arguments, and the body expression is evaluated within a lambda scope. If the result is another lambda, the current arguments are made available to the nested lambda.- Parameters:
context- the ELContext in which to evaluate the lambdaargs- the actual arguments to bind to the formal parameters- Returns:
- the result of evaluating the lambda body expression
- Throws:
ELException- if the number of arguments is less than the number of formal parameters
-
invoke
Invokes the lambda expression with the given arguments using the EL context set bysetELContext(ELContext). This is a convenience method for use when the lambda has been assigned to a functional interface variable.- Parameters:
args- the actual arguments to bind to the formal parameters- Returns:
- the result of evaluating the lambda body expression
- Throws:
ELException- if the number of arguments is less than the number of formal parameters
-