LambdaExpression (EL 6.0 API Documentation - Apache Tomcat 11.0.24)
Description: declaration: package: jakarta.el, class: LambdaExpression

# Class LambdaExpression

java.lang.Object
jakarta.el.LambdaExpression

public class LambdaExpression extends Object
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

  Constructors
  Constructor
  Description
  `LambdaExpression(List<String> formalParameters, ValueExpression expression)`
  Constructs a LambdaExpression with the given formal parameters and body expression.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `invoke(ELContext context, Object... args)`
  Invokes the lambda expression with the given arguments in the specified EL context.
  `Object`
  `invoke(Object... args)`
  Invokes the lambda expression with the given arguments using the EL context set by `setELContext(ELContext)`.
  `void`
  `setELContext(ELContext context)`
  Sets the `ELContext` to be used when this lambda is invoked without an explicit context argument.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LambdaExpression

    public LambdaExpression(List<String> formalParameters, ValueExpression expression)
    Constructs a LambdaExpression with the given formal parameters and body expression.
    Parameters:
      `formalParameters` - the list of formal parameter names for the lambda
      `expression` - the body expression to evaluate when the lambda is invoked

- ## Method Details

  - ### setELContext

    public void setELContext(ELContext context)
    Sets the `ELContext` to be used when this lambda is invoked without an explicit context argument. This is called automatically when the lambda is coerced to a functional interface type.
    Parameters:
      `context` - the ELContext to use for evaluation

  - ### invoke

    public Object invoke(ELContext context, Object... args) throws ELException
    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 lambda
      `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

  - ### invoke

    public Object invoke(Object... args)
    Invokes the lambda expression with the given arguments using the EL context set by `setELContext(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