Package io.github.chrimle.classforge
Class AbstractBuilder<T extends Builder<T>>
java.lang.Object
io.github.chrimle.classforge.AbstractBuilder<T>
- All Implemented Interfaces:
Builder<T>
- Direct Known Subclasses:
ClassBuilder,EnumBuilder
public abstract sealed class AbstractBuilder<T extends Builder<T>>
extends Object
implements Builder<T>
permits ClassBuilder, EnumBuilder
Abstract class for building and generating Java classes.
- Since:
- 0.1.0
- Author:
- Chrimle
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.chrimle.classforge.Builder
Builder.VersionPlacement -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringTheclassNameof the currently uncommitted class.protected StringThedirectoryof the currently uncommitted class.protected StringThepackageNameof the currently uncommitted class.The collection of previously committed classes.protected SemVerThesemVerof the previously committed class.protected Builder.VersionPlacementTheversionPlacementof the currently uncommitted class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncommit()Commits the currently uncommitted class.protected SemVer.ChangeDetermines theSemVer.Changefor the currently uncommitted changes.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 effective package name for the currently uncommitted class.protected StringResolves the Fully Qualified Class Name (FQCN) for the currently uncommitted class.protected abstract Tself()Returns this asAbstractBuilder.setVersionPlacement(Builder.VersionPlacement versionPlacement) Sets theversionPlacementof 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. -
semVer
ThesemVerof the previously committed class. Starts at0.0.0. -
versionPlacement
TheversionPlacementof the currently uncommitted class. -
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
-
setVersionPlacement
Sets theversionPlacementof the currently uncommitted class.Default:
Builder.VersionPlacement.NONE.- Specified by:
setVersionPlacementin interfaceBuilder<T extends Builder<T>>- Parameters:
versionPlacement- for the class.- Returns:
- this
Builder.
-
updateDirectory
Updates thedirectoryof the currently uncommitted class.- Specified by:
updateDirectoryin interfaceBuilder<T extends Builder<T>>- Parameters:
directory- of the class.- Returns:
- this
Builder.
-
updatePackageName
Updates thepackageNameof the currently uncommitted class.- Specified by:
updatePackageNamein interfaceBuilder<T extends Builder<T>>- Parameters:
packageName- of the class.- Returns:
- this
Builder.
-
updateClassName
Updates theclassNameof the currently uncommitted class.- Specified by:
updateClassNamein interfaceBuilder<T extends Builder<T>>- Parameters:
className- of the class.- Returns:
- this
Builder.
-
commit
Commits the currently uncommitted class. -
determineSemVerChange
Determines theSemVer.Changefor the currently uncommitted changes.- Returns:
- the
Change.
-
self
Returns this asAbstractBuilder.- Returns:
- this.
-
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.
-
resolveEffectivePackageName
Resolves the effective package name for the currently uncommitted class.- Returns:
- the effective package name.
-