Package io.github.chrimle.classforge
Class AbstractBuilder
java.lang.Object
io.github.chrimle.classforge.AbstractBuilder
- All Implemented Interfaces:
Builder
- Direct Known Subclasses:
ClassBuilder,EnumBuilder
public abstract sealed class AbstractBuilder
extends Object
implements Builder
permits ClassBuilder, EnumBuilder
Abstract class for building and generating Java classes.
- Since:
- 0.1.0
- Author:
- Chrimle
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncommit()Commits the currently uncommitted class.protected voidGenerates a.javaclass file for the currently uncommitted class.protected abstract StringGenerates the complete file contents for a.javafile for the currently uncommitted class.protected StringResolves the Fully Qualified Class Name (FQCN) for the currently uncommitted class.updateClassName(String className) Updates theclassNameof the currently uncommitted class.updateDirectory(String directory) Updates thedirectoryof the currently uncommitted class.updatePackageName(String packageName) Updates thepackageNameof the currently uncommitted class.protected abstract voidValidates additionalPredicates for determining the validity of the currently uncommitted class.
-
Field Details
-
reservedClassNames
The collection of previously committed classes. -
directory
Thedirectoryof the currently uncommitted class. -
packageName
ThepackageNameof the currently uncommitted class. -
className
TheclassNameof the currently uncommitted class.
-
-
Constructor Details
-
AbstractBuilder
public AbstractBuilder()
-
-
Method Details
-
updateDirectory
Updates thedirectoryof the currently uncommitted class.- Specified by:
updateDirectoryin interfaceBuilder- Parameters:
directory- of the class.- Returns:
- this
Builder.
-
updatePackageName
Updates thepackageNameof the currently uncommitted class.- Specified by:
updatePackageNamein interfaceBuilder- Parameters:
packageName- of the class.- Returns:
- this
Builder.
-
updateClassName
Updates theclassNameof the currently uncommitted class.- Specified by:
updateClassNamein interfaceBuilder- Parameters:
className- of the class.- Returns:
- this
Builder.
-
commit
Commits the currently uncommitted class. -
validateAdditionalPredicates
protected abstract void validateAdditionalPredicates()Validates additionalPredicates for determining the validity of the currently uncommitted class. -
generateFileContent
Generates the complete file contents for a.javafile for the currently uncommitted class.- Returns:
- the file contents as a
String.
-
generateClassFile
protected void generateClassFile()Generates a.javaclass file for the currently uncommitted class. -
resolveFullyQualifiedClassName
Resolves the Fully Qualified Class Name (FQCN) for the currently uncommitted class.Example:
module.sub_module.ExampleClassorAnotherExampleClass.- Returns:
- the FQCN.
-