Class LambdaDef
java.lang.Object
io.micronaut.sourcegen.model.LambdaDef
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 Summary
Modifier and TypeMethodDescriptiongetType()implement(MethodDef.MethodBodyBuilder lambdaBuilder) Implement lambda by providing the method body.implement(String[] parameterNames, MethodDef.MethodBodyBuilder lambdaBuilder) Implement lambda by providing the parameter names and the method body.implement(List<String> parameterNames, MethodDef.MethodBodyBuilder lambdaBuilder) Implement lambda by providing the parameter names and the method body.
-
Method Details
-
implement
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 nameslambdaBuilder- 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 nameslambdaBuilder- The lambda builder- Returns:
- the lambda expression
- Since:
- 2.2
-
getType
- Returns:
- The lambda type
-
getMethod
- Returns:
- The lambda method
-
getImplementation
- Returns:
- The lambda implementation
-