Package com.github.tadukoo.java
Class JavaMethodBuilder<MethodType extends JavaMethod>
java.lang.Object
com.github.tadukoo.java.JavaMethodBuilder<MethodType>
- Direct Known Subclasses:
EditableJavaMethod.EditableJavaMethodBuilder,UneditableJavaMethod.UneditableJavaMethodBuilder
Java Method Builder is used to build a new
JavaMethod. It contains the following parameters:
| Parameter | Description | Default or Required |
|---|---|---|
| sectionComment | The section comment above the method | null |
| javadoc | The Javadoc on the method |
null |
| annotations | The annotations on the method |
An empty list |
| visibility | The Visibility of the method |
Visibility.PUBLIC |
| isStatic | Whether the method is static or not | Defaults to false |
| returnType | The return type of the method | Required |
| name | The name of the method | null (used for constructors) |
| parameters | The parameters used in the method - pairs of type, then name | An empty list |
| throwTypes | The types that can be thrown by the method | An empty list |
| lines | The actual lines of code in the method | An empty list |
- Since:
- Alpha v.0.2 (within JavaMethod), Alpha v.0.4 (as a separate class)
- Version:
- Alpha v.0.4
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<JavaAnnotation>Theannotationson the methodprotected booleanWhether the method is static or notprotected JavadocTheJavadocon the methodThe actual lines of code in the methodprotected StringThe name of the methodThe parameters used in the method - pairs of type, then nameprotected StringThe return type of the methodprotected StringThe section comment above the methodThe types that can be thrown by the methodprotected VisibilityTheVisibilityof the method -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionannotation(JavaAnnotation annotation) annotations(List<JavaAnnotation> annotations) build()Checks for any errors in the current parameters, then builds a newJavaMethodChecks for errors specific to the subclassprotected abstract MethodTypeConstructs a newJavaMethodusing the set parametersisStatic()Sets the method as staticisStatic(boolean isStatic) parameters(List<com.github.tadukoo.util.tuple.Pair<String, String>> parameters) returnType(String returnType) sectionComment(String sectionComment) throwTypes(List<String> throwTypes) visibility(Visibility visibility)
-
Field Details
-
sectionComment
The section comment above the method -
javadoc
TheJavadocon the method -
annotations
Theannotationson the method -
visibility
TheVisibilityof the method -
isStatic
protected boolean isStaticWhether the method is static or not -
returnType
The return type of the method -
name
The name of the method -
parameters
The parameters used in the method - pairs of type, then name -
throwTypes
The types that can be thrown by the method -
lines
The actual lines of code in the method
-
-
Constructor Details
-
JavaMethodBuilder
protected JavaMethodBuilder()Constructs a new JavaMethodBuilder
-
-
Method Details
-
sectionComment
- Parameters:
sectionComment- The section comment above the method- Returns:
- this, to continue building
-
javadoc
- Parameters:
javadoc- TheJavadocon the method- Returns:
- this, to continue building
-
annotations
- Parameters:
annotations- Theannotationson the method- Returns:
- this, to continue building
-
annotation
- Parameters:
annotation- A singleannotationon the method- Returns:
- this, to continue building
-
visibility
- Parameters:
visibility- TheVisibilityof the method- Returns:
- this, to continue building
-
isStatic
Sets the method as static- Returns:
- this, to continue building
-
isStatic
- Parameters:
isStatic- Whether the method is static or not- Returns:
- this, to continue building
-
returnType
- Parameters:
returnType- The return type of the method- Returns:
- this, to continue building
-
name
- Parameters:
name- The name of the method- Returns:
- this, to continue building
-
parameters
public JavaMethodBuilder<MethodType> parameters(List<com.github.tadukoo.util.tuple.Pair<String, String>> parameters) - Parameters:
parameters- The parameters used in the method - pairs of type, then name- Returns:
- this, to continue building
-
parameter
public JavaMethodBuilder<MethodType> parameter(com.github.tadukoo.util.tuple.Pair<String, String> parameter) - Parameters:
parameter- A single parameter, with type first, then name - to add to the list- Returns:
- this, to continue building
-
parameter
- Parameters:
type- The type of the parameter to be addedname- The name of the parameter to be added- Returns:
- this, to continue building
-
throwTypes
- Parameters:
throwTypes- The types the method can throw- Returns:
- this, to continue building
-
throwType
- Parameters:
throwType- A type the method can throw - to add to the list- Returns:
- this, to continue building
-
lines
- Parameters:
lines- The actual lines of code in the method- Returns:
- this, to continue building
-
line
- Parameters:
line- A single line of code in the method, to add to the list- Returns:
- this, to continue building
-
checkForSpecificErrors
Checks for errors specific to the subclass- Returns:
- The errors found in the subclass, or an empty List
-
build
Checks for any errors in the current parameters, then builds a newJavaMethod- Returns:
- A newly built
JavaMethod - Throws:
IllegalArgumentException- if anything is wrong with the current parameters
-
constructMethod
Constructs a newJavaMethodusing the set parameters- Returns:
- The newly created
JavaMethod
-