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
@API(status=STABLE,
since="0.6.0")
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 io.github.chrimle.semver.SemVerThesemVerof the previously committed class.protected Builder.VersionPlacementTheversionPlacementof the currently uncommitted class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncommit()Commits the currently uncommitted changes as a new class.commit(io.github.chrimle.semver.SemVer semVer) Commits the currently uncommitted changes as a new class.protected io.github.chrimle.semver.ChangeDetermines theChangefor the currently uncommitted changes.protected voidgenerateClassFile(io.github.chrimle.semver.SemVer semVer) Generates a.javaclass file for the currently uncommitted class.protected abstract StringgenerateFileContent(io.github.chrimle.semver.SemVer semVer) Generates the complete file contents for a.javafile for the currently uncommitted class.io.github.chrimle.semver.SemVerGets thesemVerof the currently uncommitted class.protected StringresolveEffectiveClassName(io.github.chrimle.semver.SemVer semVer) Resolves the effective class name for the currently uncommitted class.protected StringresolveEffectivePackageName(io.github.chrimle.semver.SemVer semVer) Resolves the effective package name for the currently uncommitted class.protected StringresolveFullyQualifiedClassName(io.github.chrimle.semver.SemVer semVer) Resolves the Fully Qualified Class Name (FQCN) for the currently uncommitted class.protected abstract Tself()Returns this asAbstractBuilder.setSemVer(io.github.chrimle.semver.SemVer semVer) Sets thesemVerof the currently uncommitted class.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 voidValidates additionalPredicates for determining the validity of the currently uncommitted class.
-
Field Details
-
reservedClassNames
The collection of previously committed classes. -
semVer
protected io.github.chrimle.semver.SemVer semVerThesemVerof 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
-
getSemVer
@NotNull public io.github.chrimle.semver.SemVer getSemVer()Gets thesemVerof the currently uncommitted class. NOTE: thesemVerwill be updated when committing the changes. -
setSemVer
Sets thesemVerof the currently uncommitted class.NOTE: the
semVerwill be updated when committing the changes. -
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 changes as a new class. ThesemVerof the new class will be set automatically. -
commit
Commits the currently uncommitted changes as a new class. ThesemVerof the new class will be set to the givensemVer. -
determineSemVerChange
protected io.github.chrimle.semver.Change determineSemVerChange()Determines theChangefor the currently uncommitted changes.- Returns:
- the
Change.
-
self
Returns this asAbstractBuilder.- Returns:
- this.
-
validateAdditionalPredicates
protected 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.- Parameters:
semVer- for the new class.- Returns:
- the file contents as a
String.
-
generateClassFile
protected void generateClassFile(io.github.chrimle.semver.SemVer semVer) Generates a.javaclass file for the currently uncommitted class.- Parameters:
semVer- for the new class.
-
resolveFullyQualifiedClassName
Resolves the Fully Qualified Class Name (FQCN) for the currently uncommitted class.Example:
module.sub_module.ExampleClassorAnotherExampleClass.- Parameters:
semVer- for the new class.- Returns:
- the FQCN.
-
resolveEffectivePackageName
Resolves the effective package name for the currently uncommitted class.- Parameters:
semVer- for the class.- Returns:
- the effective package name.
-
resolveEffectiveClassName
Resolves the effective class name for the currently uncommitted class.- Parameters:
semVer- for the class.- Returns:
- the effective class name.
-