Package io.github.chrimle.classforge
Class EnumBuilder
- All Implemented Interfaces:
Builder<EnumBuilder>
@API(status=STABLE,
since="0.6.0")
public final class EnumBuilder
extends AbstractBuilder<EnumBuilder>
Builder of Java
enum 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 TypeFieldDescriptionstatic final StringThe RegularExpression (RegEx) for determining validity of enum constant-names.Fields inherited from class io.github.chrimle.classforge.AbstractBuilder
className, directory, packageName, reservedClassNames, semVer, versionPlacement -
Method Summary
Modifier and TypeMethodDescriptionaddEnumConstants(String... enumConstantNames) Adds theenumConstantNamesto the currently uncommitted enum class.protected StringgenerateFileContent(SemVer semVer) Generates the complete file contents for a.javafile for the currently uncommitted class.removeEnumConstants(String... enumConstantNames) Removes theenumConstantNamesfrom the currently uncommitted enum class.protected EnumBuilderself()Returns this asAbstractBuilder.updateEnumConstant(String oldEnumConstant, String newEnumConstant) Updates theoldEnumConstantintonewEnumConstantin the currently uncommitted class.Methods inherited from class io.github.chrimle.classforge.AbstractBuilder
commit, commit, determineSemVerChange, generateClassFile, getSemVer, resolveEffectivePackageName, resolveFullyQualifiedClassName, setSemVer, setVersionPlacement, updateClassName, updateDirectory, updatePackageName, validateAdditionalPredicates
-
Field Details
-
VALID_ENUM_CONSTANT_NAME_REGEX
The RegularExpression (RegEx) for determining validity of enum constant-names.- Since:
- 0.2.0
- See Also:
-
-
Method Details
-
addEnumConstants
@Contract("null -> fail; _ -> this") public EnumBuilder addEnumConstants(String... enumConstantNames) Adds theenumConstantNamesto the currently uncommitted enum class.- Parameters:
enumConstantNames- to add.- Returns:
- this Builder.
- Throws:
IllegalArgumentException- ifenumConstantNamesisnull.IllegalArgumentException- ifenumConstantNamesis empty.IllegalArgumentException- ifenumConstantNamescontain aStringwhich isnull.IllegalArgumentException- ifenumConstantNamescontain aStringwhich does not match the RegEx "^([A-Za-z]|(_+[A-Za-z0-9]))[A-Z_a-z0-9]*$".IllegalArgumentException- ifenumConstantNamescontain aStringwhich does not exist in the currently uncommitted class.- Since:
- 0.3.0
-
removeEnumConstants
@Contract("null -> fail; _ -> this") public EnumBuilder removeEnumConstants(String... enumConstantNames) Removes theenumConstantNamesfrom the currently uncommitted enum class.- Parameters:
enumConstantNames- to remove.- Returns:
- this Builder.
- Throws:
IllegalArgumentException- ifenumConstantNamesisnull.IllegalArgumentException- ifenumConstantNamesis empty.IllegalArgumentException- ifenumConstantNamescontain aStringwhich isnull.IllegalArgumentException- ifenumConstantNamescontain aStringwhich does not exist in the currently uncommitted class.- Since:
- 0.3.0
-
updateEnumConstant
@Contract("null, _ -> fail; _, null -> fail; _, _ -> this") public EnumBuilder updateEnumConstant(String oldEnumConstant, String newEnumConstant) Updates theoldEnumConstantintonewEnumConstantin the currently uncommitted class.- Parameters:
oldEnumConstant- to be removed.newEnumConstant- to be added.- Returns:
- this Builder.
- Throws:
IllegalArgumentException- ifoldEnumConstantisnull.IllegalArgumentException- ifoldEnumConstantdoes not exist.IllegalArgumentException- ifnewEnumConstantisnull.IllegalArgumentException- ifnewEnumConstantdoes not match the RegEx "^([A-Za-z]|(_+[A-Za-z0-9]))[A-Z_a-z0-9]*$".IllegalArgumentException- ifnewEnumConstantalready exists.- Since:
- 0.5.0
-
self
Description copied from class:AbstractBuilderReturns this asAbstractBuilder.- Specified by:
selfin classAbstractBuilder<EnumBuilder>- Returns:
- this.
-
generateFileContent
Description copied from class:AbstractBuilderGenerates the complete file contents for a.javafile for the currently uncommitted class.- Specified by:
generateFileContentin classAbstractBuilder<EnumBuilder>- Parameters:
semVer- for the new class.- Returns:
- the file contents as a
String.
-