Package com.github.tadukoo.java.method
Class JavaMethodBuilder<MethodType extends JavaMethod>
java.lang.Object
com.github.tadukoo.java.method.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 |
|---|---|---|
| javadoc | The Javadoc on the method |
null |
| annotations | The annotations on the method |
An empty list |
| visibility | The Visibility of the method |
Visibility.NONE |
| isAbstract | Whether the method is abstract or not | Defaults to false |
| isStatic | Whether the method is static or not | Defaults to false |
| isFinal | Whether the method is final 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:
- Beta v.0.5
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<JavaAnnotation>Theannotationson the methodprotected booleanWhether the method is abstract or notprotected booleanWhether the method is final or notprotected 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 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 parameterscopy(JavaMethod method) Copies the settings from the givenmethodto this builderSets the method as abstractisAbstract(boolean isAbstract) isFinal()Sets the method as finalisFinal(boolean isFinal) isStatic()Sets the method as staticisStatic(boolean isStatic) parameters(List<com.github.tadukoo.util.tuple.Pair<String, String>> parameters) returnType(String returnType) throwTypes(List<String> throwTypes) visibility(Visibility visibility)
-
Field Details
-
javadoc
TheJavadocon the method -
annotations
Theannotationson the method -
visibility
TheVisibilityof the method -
isAbstract
protected boolean isAbstractWhether the method is abstract or not -
isStatic
protected boolean isStaticWhether the method is static or not -
isFinal
protected boolean isFinalWhether the method is final 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
-
copy
Copies the settings from the givenmethodto this builder- Parameters:
method- Themethodto copy settings from- 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
-
isAbstract
Sets the method as abstract- Returns:
- this, to continue building
-
isAbstract
- Parameters:
isAbstract- Whether the method is abstract or not- 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
-
isFinal
Sets the method as final- Returns:
- this, to continue building
-
isFinal
- Parameters:
isFinal- Whether the method is final 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
-