Class LambdaDef

java.lang.Object
io.micronaut.sourcegen.model.LambdaDef

public final class LambdaDef extends Object
Definition holding information about a lambda interface that can be implemented. Use ClassTypeDef.getLambda() to create an instance from an existing type definition.
Since:
1.7
Author:
Denis Stepanov
  • Method Details

    • implement

      public ExpressionDef.Lambda implement(MethodDef.MethodBodyBuilder lambdaBuilder)
      Implement lambda by providing the method body.
      Parameters:
      lambdaBuilder - The lambda builder
      Returns:
      the lambda expression
      Since:
      1.7
    • implement

      public ExpressionDef.Lambda implement(List<String> parameterNames, MethodDef.MethodBodyBuilder lambdaBuilder)
      Implement lambda by providing the parameter names and the method body.

      The implementation carries the parameter names of the functional interface's own method, so every lambda over the same interface declares the same names. Java forbids a lambda parameter from shadowing a name that is already in scope, which makes nested lambdas over one interface fail to compile; naming the parameters explicitly avoids the collision.

      Parameters:
      parameterNames - The lambda parameter names
      lambdaBuilder - The lambda builder
      Returns:
      the lambda expression
      Since:
      2.2
    • implement

      public ExpressionDef.Lambda implement(String[] parameterNames, MethodDef.MethodBodyBuilder lambdaBuilder)
      Implement lambda by providing the parameter names and the method body.
      Parameters:
      parameterNames - The lambda parameter names
      lambdaBuilder - The lambda builder
      Returns:
      the lambda expression
      Since:
      2.2
    • getType

      public ClassTypeDef getType()
      Returns:
      The lambda type
    • getMethod

      public MethodDef getMethod()
      Returns:
      The lambda method
    • getImplementation

      public MethodDef getImplementation()
      Returns:
      The lambda implementation