Package io.micronaut.sourcegen.model
Class MethodDef.MethodDefBuilder
java.lang.Object
io.micronaut.sourcegen.model.AbstractElementBuilder<MethodDef.MethodDefBuilder>
io.micronaut.sourcegen.model.MethodDef.MethodDefBuilder
- Enclosing class:
- MethodDef
public static final class MethodDef.MethodDefBuilder
extends AbstractElementBuilder<MethodDef.MethodDefBuilder>
The method builder definition.
- Since:
- 1.0
- Author:
- Denis Stepanov
-
Field Summary
Fields inherited from class io.micronaut.sourcegen.model.AbstractElementBuilder
annotations, javadoc, modifiers, name, thisInstance
-
Method Summary
Modifier and TypeMethodDescription@NonNull MethodDef.MethodDefBuilder
addParameter
(@NonNull ParameterDef parameterDef) Add a parameter.@NonNull MethodDef.MethodDefBuilder
addParameter
(@NonNull TypeDef type) Add a parameter.@NonNull MethodDef.MethodDefBuilder
addParameter
(@NonNull Class<?> type) Add a parameter.@NonNull MethodDef.MethodDefBuilder
addParameter
(@NonNull String name, @NonNull TypeDef type) Add a parameter.@NonNull MethodDef.MethodDefBuilder
addParameter
(@NonNull String name, @NonNull Class<?> type) Add a parameter.@NonNull MethodDef.MethodDefBuilder
addParameters
(@NonNull TypeDef... types) Add parameters.@NonNull MethodDef.MethodDefBuilder
addParameters
(@NonNull Class<?>... types) Add a parameters.@NonNull MethodDef.MethodDefBuilder
addParameters
(@NonNull Collection<ParameterDef> parameters) Add parameters.@NonNull MethodDef.MethodDefBuilder
addParameters
(@NonNull List<TypeDef> types) Add parameters.@NonNull MethodDef.MethodDefBuilder
addStatement
(@NonNull StatementDef statement) Add a statement to the method body.@NonNull MethodDef.MethodDefBuilder
addStatement
(MethodDef.MethodBodyBuilder bodyBuilder) Add a statement to the method body.@NonNull MethodDef.MethodDefBuilder
addStatements
(@NonNull Collection<StatementDef> newStatements) Add statements to the method body.@NonNull MethodDef.MethodDefBuilder
addStaticStatement
(@NonNull Function<List<VariableDef.MethodParameter>, StatementDef> bodyBuilder) Add a statement to the static method body.build()
@NonNull MethodDef
build
(MethodDef.MethodBodyBuilder bodyBuilder) Build a method with a body builder.@NonNull MethodDef
buildStatic
(@NonNull Function<List<VariableDef.MethodParameter>, StatementDef> bodyBuilder) Build a static method with a body builder.Mark the method as an override.overrides
(boolean overrides) Mark the method as an override.The return type of the method.Methods inherited from class io.micronaut.sourcegen.model.AbstractElementBuilder
addAnnotation, addAnnotation, addAnnotation, addAnnotation, addAnnotations, addAnnotations, addJavadoc, addModifiers, addModifiers, overrideModifiers
-
Method Details
-
returns
The return type of the method. In a case of missing return type it will be extracted from the statements.- Parameters:
type
- The return type- Returns:
- the current builder
-
overrides
Mark the method as an override.- Returns:
- the current builder
-
overrides
Mark the method as an override.- Parameters:
overrides
- The value- Returns:
- the current builder
-
returns
-
addParameter
@NonNull public @NonNull MethodDef.MethodDefBuilder addParameter(@NonNull @NonNull String name, @NonNull @NonNull TypeDef type) Add a parameter.- Parameters:
name
- The nametype
- The type- Returns:
- a builder
- Since:
- 1.5
-
addParameter
Add a parameter.- Parameters:
type
- The type- Returns:
- a builder
- Since:
- 1.5
-
addParameter
@NonNull public @NonNull MethodDef.MethodDefBuilder addParameter(@NonNull @NonNull ParameterDef parameterDef) Add a parameter.- Parameters:
parameterDef
- The parameter def- Returns:
- a builder
- Since:
- 1.5
-
addParameters
@NonNull public @NonNull MethodDef.MethodDefBuilder addParameters(@NonNull @NonNull Collection<ParameterDef> parameters) Add parameters.- Parameters:
parameters
- The parameters- Returns:
- a builder
- Since:
- 1.5
-
addParameter
@NonNull public @NonNull MethodDef.MethodDefBuilder addParameter(@NonNull @NonNull String name, @NonNull @NonNull Class<?> type) Add a parameter.- Parameters:
name
- The nametype
- The type- Returns:
- a builder
-
addParameter
Add a parameter.- Parameters:
type
- The type- Returns:
- a builder
- Since:
- 1.5
-
addParameters
@NonNull public @NonNull MethodDef.MethodDefBuilder addParameters(@NonNull @NonNull Class<?>... types) Add a parameters.- Parameters:
types
- The types- Returns:
- a builder
- Since:
- 1.5
-
addParameters
@NonNull public @NonNull MethodDef.MethodDefBuilder addParameters(@NonNull @NonNull TypeDef... types) Add parameters.- Parameters:
types
- The types- Returns:
- a builder
- Since:
- 1.5
-
addParameters
@NonNull public @NonNull MethodDef.MethodDefBuilder addParameters(@NonNull @NonNull List<TypeDef> types) Add parameters.- Parameters:
types
- The types- Returns:
- a builder
- Since:
- 1.5
-
addStaticStatement
@NonNull public @NonNull MethodDef.MethodDefBuilder addStaticStatement(@NonNull @NonNull Function<List<VariableDef.MethodParameter>, StatementDef> bodyBuilder) Add a statement to the static method body.- Parameters:
bodyBuilder
- The builder- Returns:
- The builder
- Since:
- 1.5
-
addStatement
@NonNull public @NonNull MethodDef.MethodDefBuilder addStatement(@NonNull @NonNull StatementDef statement) Add a statement to the method body.- Parameters:
statement
- The statement- Returns:
- The builder
-
addStatement
@NonNull public @NonNull MethodDef.MethodDefBuilder addStatement(@NonNull MethodDef.MethodBodyBuilder bodyBuilder) Add a statement to the method body.- Parameters:
bodyBuilder
- The body builder- Returns:
- The builder
-
addStatements
@NonNull public @NonNull MethodDef.MethodDefBuilder addStatements(@NonNull @NonNull Collection<StatementDef> newStatements) Add statements to the method body.- Parameters:
newStatements
- The new statements- Returns:
- The builder
-
build
-
build
Build a method with a body builder.- Parameters:
bodyBuilder
- The body builder- Returns:
- The builder
-
buildStatic
@NonNull public @NonNull MethodDef buildStatic(@NonNull @NonNull Function<List<VariableDef.MethodParameter>, StatementDef> bodyBuilder) Build a static method with a body builder.- Parameters:
bodyBuilder
- The body builder- Returns:
- The builder
-