Package com.github.tadukoo.java
Class JavaClassBuilder<ClassType extends JavaClass>
java.lang.Object
com.github.tadukoo.java.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 |
| packageName | The name of the package the class is in | Required |
| imports | The classes imported by the class | An empty list |
| staticImports | The classes imported statically by 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.PUBLIC |
| isStatic | Whether the class is static or not | false |
| className | The name of the class | Required |
| superClassName | The name of the class this one extends (may be null) | null |
| 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 |
- Since:
- Alpha v.0.2 (in JavaClass), 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 classprotected StringThe name of the classThefieldson the classThe classes imported by the classInnerclassesinside the classprotected booleanWhether the class is an inner class or notprotected booleanWhether the class is static or notprotected JavadocTheJavadocfor the classprotected List<JavaMethod>Themethodsin the classprotected StringThe name of the package the class is inThe classes imported statically by the classprotected StringThe name of the class this one extends (may 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 parametersSet the class as an inner classinnerClass(JavaClass innerClass) innerClasses(List<JavaClass> innerClasses) isInnerClass(boolean isInnerClass) isStatic()Sets isStatic to true, defining the class as a static classisStatic(boolean isStatic) method(JavaMethod method) methods(List<JavaMethod> methods) packageName(String packageName) singleImport(String singleImport) staticImport(String staticImport) staticImports(List<String> staticImports) superClassName(String superClassName) visibility(Visibility visibility)
-
Field Details
-
isInnerClass
protected boolean isInnerClassWhether the class is an inner class or not -
packageName
The name of the package the class is in -
imports
The classes imported by the class -
staticImports
The classes imported statically by the class -
javadoc
TheJavadocfor the class -
annotations
Theannotationson the class -
visibility
TheVisibilityof the class -
isStatic
protected boolean isStaticWhether the class is static or not -
className
The name of the class -
superClassName
The name of the class this one extends (may be null) -
innerClasses
Innerclassesinside the class -
fields
Thefieldson the class -
methods
Themethodsin the class
-
-
Constructor Details
-
JavaClassBuilder
protected JavaClassBuilder()Constructs a newJavaClassBuilder
-
-
Method Details
-
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
-
packageName
- Parameters:
packageName- The name of the package the class is in- Returns:
- this, to continue building
-
imports
- Parameters:
imports- The classes imported by the class- Returns:
- this, to continue building
-
singleImport
- Parameters:
singleImport- A single class imported by the class, to be added to the list- Returns:
- this, to continue building
-
staticImports
- Parameters:
staticImports- The classes imported statically by the class- Returns:
- this, to continue building
-
staticImport
- Parameters:
staticImport- A single class imported statically by the class, to be added to the list- 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
-
isStatic
- Parameters:
isStatic- Whether the class is static or not- Returns:
- this, to continue building
-
isStatic
Sets isStatic to true, defining the class as a static class- 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
-
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
-
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
-