Class JavaClassBuilder<ClassType extends JavaClass>
java.lang.Object
com.github.tadukoo.java.javaclass.JavaClassBuilder<ClassType>
- Direct Known Subclasses:
EditableJavaClass.EditableJavaClassBuilder,UneditableJavaClass.UneditableJavaClassBuilder
Java Class Builder is used to create a
JavaClass. It has the following parameters:
| Parameter | Description | Default or Required |
|---|---|---|
| isInnerClass | Whether the class is an inner class or not | Defaults to false |
| packageDeclaration | The package declaration of the class |
Defaults to null |
| importStatements | The import statements of the class |
An empty list |
| javadoc | The Javadoc for the class |
Defaults to null |
| annotations | The annotations on the class |
An empty list |
| visibility | The Visibility of the class |
Visibility.NONE |
| isAbstract | Whether the class is abstract or not | false |
| isStatic | Whether the class is static or not | false |
| isFinal | Whether the class is final or not | false |
| className | The name of the class | Required |
| superClassName | The name of the class this one extends (may be null) | null |
| implementsInterfaceNames | The names of interfaces this class implements | An empty List |
| singleLineComments | The single-line comments inside the class |
An empty List |
| multiLineComments | The multi-line comments inside the class |
An empty List |
| innerClasses | Inner classes inside the class |
An empty list |
| fields | The fields on the class |
An empty list |
| methods | The methods in the class |
An empty list |
| innerElementsOrder | The order of the elements inside the class | The order they were added in, Required if there are comments |
- Since:
- Alpha v.0.2 (in JavaClass), 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 classprotected StringThe name of the classThefieldson the classThe names of interfaces the class implementsprotected List<JavaImportStatement>Theimport statementsof the classInnerclassesinside the classprotected List<com.github.tadukoo.util.tuple.Pair<JavaCodeTypes,String>> The order of the elements inside the classprotected booleanWhether the class is abstract or notprotected booleanWhether the class is final or notprotected booleanWhether the class is an inner class or notprotected booleanWhether the class is static or notprotected JavadocTheJavadocfor the classprotected List<JavaMethod>Themethodsin the classprotected List<JavaMultiLineComment>Themulti-line commentsinside the classprotected JavaPackageDeclarationThepackage declarationof the classprotected List<JavaSingleLineComment>Thesingle-line commentsinside the classprotected StringThe name of the class this one extends (can be null)protected VisibilityTheVisibilityof the class -
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 newJavaClassChecks for errors in the specific subclass and returns themprotected abstract ClassTypeConstructs aJavaClassusing the set parametersCopies the settings from the givenclassto this builderprotected abstract JavaImportStatementBuilder<?>protected abstract JavaPackageDeclarationBuilder<?>implementsInterfaceName(String implementsInterfaceName) implementsInterfaceNames(List<String> implementsInterfaceNames) importName(String importName, boolean isStatic) importNames(List<String> importNames, boolean isStatic) importStatement(JavaImportStatement importStatement) importStatements(List<JavaImportStatement> importStatements) Set the class as an inner classinnerClass(JavaClass innerClass) innerClasses(List<JavaClass> innerClasses) innerElementsOrder(List<com.github.tadukoo.util.tuple.Pair<JavaCodeTypes, String>> innerElementsOrder) Sets isAbstract to true, defining the class as an abstract classisAbstract(boolean isAbstract) isFinal()Sets isFinal to true, definining the class as a final classisFinal(boolean isFinal) isInnerClass(boolean isInnerClass) isStatic()Sets isStatic to true, defining the class as a static classisStatic(boolean isStatic) method(JavaMethod method) methods(List<JavaMethod> methods) multiLineComment(JavaMultiLineComment multiLineComment) multiLineComments(List<JavaMultiLineComment> multiLineComments) packageDeclaration(JavaPackageDeclaration packageDeclaration) packageName(String packageName) singleLineComment(JavaSingleLineComment singleLineComment) singleLineComments(List<JavaSingleLineComment> singleLineComments) superClassName(String superClassName) visibility(Visibility visibility)
-
Field Details
-
isInnerClass
protected boolean isInnerClassWhether the class is an inner class or not -
packageDeclaration
Thepackage declarationof the class -
importStatements
Theimport statementsof the class -
javadoc
TheJavadocfor the class -
annotations
Theannotationson the class -
visibility
TheVisibilityof the class -
isAbstract
protected boolean isAbstractWhether the class is abstract or not -
isStatic
protected boolean isStaticWhether the class is static or not -
isFinal
protected boolean isFinalWhether the class is final or not -
className
The name of the class -
superClassName
The name of the class this one extends (can be null) -
implementsInterfaceNames
The names of interfaces the class implements -
singleLineComments
Thesingle-line commentsinside the class -
multiLineComments
Themulti-line commentsinside the class -
innerClasses
Innerclassesinside the class -
fields
Thefieldson the class -
methods
Themethodsin the class -
innerElementsOrder
The order of the elements inside the class
-
-
Constructor Details
-
JavaClassBuilder
protected JavaClassBuilder()Constructs a newJavaClassBuilder
-
-
Method Details
-
copy
Copies the settings from the givenclassto this builder- Parameters:
clazz- Theclassto copy settings from- Returns:
- this, to continue building
-
isInnerClass
- Parameters:
isInnerClass- Whether the class is an inner class or not- Returns:
- this, to continue building
-
innerClass
Set the class as an inner class- Returns:
- this, to continue building
-
packageDeclaration
- Parameters:
packageDeclaration- Thepackage declarationof the class- Returns:
- this, to continue building
-
getPackageDeclarationBuilder
- Returns:
- A
JavaPackageDeclarationBuilderto use to build aJavaPackageDeclaration
-
packageName
- Parameters:
packageName- The package name to use for the class, which gets put into aJavaPackageDeclaration- Returns:
- this, to continue building
-
importStatement
- Parameters:
importStatement- Animport statementof the class- Returns:
- this, to continue building
-
importStatements
- Parameters:
importStatements- Theimport statementsof the class- Returns:
- this, to continue building
-
getImportStatementBuilder
- Returns:
- A
JavaImportStatementBuilderto use to build aJavaImportStatement
-
importName
- Parameters:
importName- The name of an import for the class (will be made into aJavaImportStatement)isStatic- Whether the import is static or not- Returns:
- this, to continue building
-
importNames
- Parameters:
importNames- The names of imports for the class (will be made intoimport statements)isStatic- Whether the imports are static or not- Returns:
- this, to continue building
-
javadoc
- Parameters:
javadoc- TheJavadocfor the class- Returns:
- this, to continue building
-
annotations
- Parameters:
annotations- Theannotationson the class- Returns:
- this, to continue building
-
annotation
- Parameters:
annotation- A singleannotationon the class- Returns:
- this, to continue building
-
visibility
- Parameters:
visibility- TheVisibilityof the class- Returns:
- this, to continue building
-
isAbstract
Sets isAbstract to true, defining the class as an abstract class- Returns:
- this, to continue building
-
isAbstract
- Parameters:
isAbstract- Whether the class is abstract or not- Returns:
- this, to continue building
-
isStatic
Sets isStatic to true, defining the class as a static class- Returns:
- this, to continue building
-
isStatic
- Parameters:
isStatic- Whether the class is static or not- Returns:
- this, to continue building
-
isFinal
Sets isFinal to true, definining the class as a final class- Returns:
- this, to continue building
-
isFinal
- Parameters:
isFinal- Whether the class is final or not- Returns:
- this, to continue building
-
className
- Parameters:
className- The name of the class- Returns:
- this, to continue building
-
superClassName
- Parameters:
superClassName- The name of the class this one extends (may be null)- Returns:
- this, to continue building
-
implementsInterfaceName
- Parameters:
implementsInterfaceName- The name of an interface this class implements- Returns:
- this, to continue building
-
implementsInterfaceNames
- Parameters:
implementsInterfaceNames- The names of interfaces this class implements- Returns:
- this, to continue building
-
singleLineComments
public JavaClassBuilder<ClassType> singleLineComments(List<JavaSingleLineComment> singleLineComments) - Parameters:
singleLineComments- Thesingle-line commentsinside the class- Returns:
- this, to continue building
-
singleLineComment
- Parameters:
singleLineComment- Asingle-line commentinside the class to add to the list- Returns:
- this, to continue building
-
multiLineComments
- Parameters:
multiLineComments- Themulti-line commentsinside the class- Returns:
- this, to continue building
-
multiLineComment
- Parameters:
multiLineComment- Amulti-line commentinside the class to add to the list- Returns:
- this, to continue building
-
innerClasses
- Parameters:
innerClasses- Innerclassesinside the class- Returns:
- this, to continue building
-
innerClass
- Parameters:
innerClass- An innerclassinside the class to be added to the list- Returns:
- this, to continue building
-
fields
- Parameters:
fields- Thefieldson the class- Returns:
- this, to continue building
-
field
- Parameters:
field- Afieldon the class, to be added to the list- Returns:
- this, to continue building
-
methods
- Parameters:
methods- Themethodsin the class- Returns:
- this, to continue building
-
method
- Parameters:
method- Amethodin the class, to be added to the list- Returns:
- this, to continue building
-
innerElementsOrder
public JavaClassBuilder<ClassType> innerElementsOrder(List<com.github.tadukoo.util.tuple.Pair<JavaCodeTypes, String>> innerElementsOrder) - Parameters:
innerElementsOrder- The order of elements inside the class- Returns:
- this, to continue building
-
checkForSpecificErrors
Checks for errors in the specific subclass and returns them- Returns:
- A list of errors, or an empty list if no errors
-
build
Checks for any errors in the current parameters, then builds a newJavaClass- Returns:
- A newly built
JavaClass - Throws:
IllegalArgumentException- if anything is wrong with the current parameters
-
constructClass
Constructs aJavaClassusing the set parameters- Returns:
- The newly built
JavaClass
-