Class JavaClassBuilder<ClassType extends JavaClass>

java.lang.Object
com.github.tadukoo.java.JavaClassBuilder<ClassType>
Direct Known Subclasses:
EditableJavaClass.EditableJavaClassBuilder, UneditableJavaClass.UneditableJavaClassBuilder

public abstract class JavaClassBuilder<ClassType extends JavaClass> extends Object
Java Class Builder is used to create a JavaClass. It has the following parameters:
Java Class 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 Details

    • isInnerClass

      protected boolean isInnerClass
      Whether the class is an inner class or not
    • packageName

      protected String packageName
      The name of the package the class is in
    • imports

      protected List<String> imports
      The classes imported by the class
    • staticImports

      protected List<String> staticImports
      The classes imported statically by the class
    • javadoc

      protected Javadoc javadoc
      The Javadoc for the class
    • annotations

      protected List<JavaAnnotation> annotations
      The annotations on the class
    • visibility

      protected Visibility visibility
      The Visibility of the class
    • isStatic

      protected boolean isStatic
      Whether the class is static or not
    • className

      protected String className
      The name of the class
    • superClassName

      protected String superClassName
      The name of the class this one extends (may be null)
    • innerClasses

      protected List<JavaClass> innerClasses
      Inner classes inside the class
    • fields

      protected List<JavaField> fields
      The fields on the class
    • methods

      protected List<JavaMethod> methods
      The methods in the class
  • Constructor Details

    • JavaClassBuilder

      protected JavaClassBuilder()
      Constructs a new JavaClassBuilder
  • Method Details

    • isInnerClass

      public JavaClassBuilder<ClassType> isInnerClass(boolean isInnerClass)
      Parameters:
      isInnerClass - Whether the class is an inner class or not
      Returns:
      this, to continue building
    • innerClass

      public JavaClassBuilder<ClassType> innerClass()
      Set the class as an inner class
      Returns:
      this, to continue building
    • packageName

      public JavaClassBuilder<ClassType> packageName(String packageName)
      Parameters:
      packageName - The name of the package the class is in
      Returns:
      this, to continue building
    • imports

      public JavaClassBuilder<ClassType> imports(List<String> imports)
      Parameters:
      imports - The classes imported by the class
      Returns:
      this, to continue building
    • singleImport

      public JavaClassBuilder<ClassType> singleImport(String singleImport)
      Parameters:
      singleImport - A single class imported by the class, to be added to the list
      Returns:
      this, to continue building
    • staticImports

      public JavaClassBuilder<ClassType> staticImports(List<String> staticImports)
      Parameters:
      staticImports - The classes imported statically by the class
      Returns:
      this, to continue building
    • staticImport

      public JavaClassBuilder<ClassType> staticImport(String staticImport)
      Parameters:
      staticImport - A single class imported statically by the class, to be added to the list
      Returns:
      this, to continue building
    • javadoc

      public JavaClassBuilder<ClassType> javadoc(Javadoc javadoc)
      Parameters:
      javadoc - The Javadoc for the class
      Returns:
      this, to continue building
    • annotations

      public JavaClassBuilder<ClassType> annotations(List<JavaAnnotation> annotations)
      Parameters:
      annotations - The annotations on the class
      Returns:
      this, to continue building
    • annotation

      public JavaClassBuilder<ClassType> annotation(JavaAnnotation annotation)
      Parameters:
      annotation - A single annotation on the class
      Returns:
      this, to continue building
    • visibility

      public JavaClassBuilder<ClassType> visibility(Visibility visibility)
      Parameters:
      visibility - The Visibility of the class
      Returns:
      this, to continue building
    • isStatic

      public JavaClassBuilder<ClassType> isStatic(boolean isStatic)
      Parameters:
      isStatic - Whether the class is static or not
      Returns:
      this, to continue building
    • isStatic

      public JavaClassBuilder<ClassType> isStatic()
      Sets isStatic to true, defining the class as a static class
      Returns:
      this, to continue building
    • className

      public JavaClassBuilder<ClassType> className(String className)
      Parameters:
      className - The name of the class
      Returns:
      this, to continue building
    • superClassName

      public JavaClassBuilder<ClassType> superClassName(String superClassName)
      Parameters:
      superClassName - The name of the class this one extends (may be null)
      Returns:
      this, to continue building
    • innerClasses

      public JavaClassBuilder<ClassType> innerClasses(List<JavaClass> innerClasses)
      Parameters:
      innerClasses - Inner classes inside the class
      Returns:
      this, to continue building
    • innerClass

      public JavaClassBuilder<ClassType> innerClass(JavaClass innerClass)
      Parameters:
      innerClass - An inner class inside the class to be added to the list
      Returns:
      this, to continue building
    • fields

      public JavaClassBuilder<ClassType> fields(List<JavaField> fields)
      Parameters:
      fields - The fields on the class
      Returns:
      this, to continue building
    • field

      public JavaClassBuilder<ClassType> field(JavaField field)
      Parameters:
      field - A field on the class, to be added to the list
      Returns:
      this, to continue building
    • methods

      public JavaClassBuilder<ClassType> methods(List<JavaMethod> methods)
      Parameters:
      methods - The methods in the class
      Returns:
      this, to continue building
    • method

      public JavaClassBuilder<ClassType> method(JavaMethod method)
      Parameters:
      method - A method in the class, to be added to the list
      Returns:
      this, to continue building
    • checkForSpecificErrors

      protected abstract List<String> checkForSpecificErrors()
      Checks for errors in the specific subclass and returns them
      Returns:
      A list of errors, or an empty list if no errors
    • build

      public ClassType build()
      Checks for any errors in the current parameters, then builds a new JavaClass
      Returns:
      A newly built JavaClass
      Throws:
      IllegalArgumentException - if anything is wrong with the current parameters
    • constructClass

      protected abstract ClassType constructClass()
      Constructs a JavaClass using the set parameters
      Returns:
      The newly built JavaClass