Package io.github.chrimle.classforge
Class EnumBuilder
- All Implemented Interfaces:
Builder<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 String
The 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 theenumConstantNames
to the currently uncommitted enum class.protected String
generateFileContent
(SemVer semVer) Generates the complete file contents for a.java
file for the currently uncommitted class.removeEnumConstants
(String... enumConstantNames) Removes theenumConstantNames
from the currently uncommitted enum class.protected EnumBuilder
self()
Returns this asAbstractBuilder
.updateEnumConstant
(String oldEnumConstant, String newEnumConstant) Updates theoldEnumConstant
intonewEnumConstant
in the currently uncommitted class.Methods inherited from class io.github.chrimle.classforge.AbstractBuilder
commit, commit, determineSemVerChange, generateClassFile, 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 theenumConstantNames
to the currently uncommitted enum class.- Parameters:
enumConstantNames
- to add.- Returns:
- this Builder.
- Throws:
IllegalArgumentException
- ifenumConstantNames
isnull
.IllegalArgumentException
- ifenumConstantNames
is empty.IllegalArgumentException
- ifenumConstantNames
contain aString
which isnull
.IllegalArgumentException
- ifenumConstantNames
contain aString
which does not match the RegEx "^([A-Za-z]|(_+[A-Za-z0-9]))[A-Z_a-z0-9]*$".IllegalArgumentException
- ifenumConstantNames
contain aString
which does not exist in the currently uncommitted class.- Since:
- 0.3.0
-
removeEnumConstants
@Contract("null -> fail; _ -> this") public EnumBuilder removeEnumConstants(String... enumConstantNames) Removes theenumConstantNames
from the currently uncommitted enum class.- Parameters:
enumConstantNames
- to remove.- Returns:
- this Builder.
- Throws:
IllegalArgumentException
- ifenumConstantNames
isnull
.IllegalArgumentException
- ifenumConstantNames
is empty.IllegalArgumentException
- ifenumConstantNames
contain aString
which isnull
.IllegalArgumentException
- ifenumConstantNames
contain aString
which 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 theoldEnumConstant
intonewEnumConstant
in the currently uncommitted class.- Parameters:
oldEnumConstant
- to be removed.newEnumConstant
- to be added.- Returns:
- this Builder.
- Throws:
IllegalArgumentException
- ifoldEnumConstant
isnull
.IllegalArgumentException
- ifoldEnumConstant
does not exist.IllegalArgumentException
- ifnewEnumConstant
isnull
.IllegalArgumentException
- ifnewEnumConstant
does not match the RegEx "^([A-Za-z]|(_+[A-Za-z0-9]))[A-Z_a-z0-9]*$".IllegalArgumentException
- ifnewEnumConstant
already exists.- Since:
- 0.5.0
-
self
Description copied from class:AbstractBuilder
Returns this asAbstractBuilder
.- Specified by:
self
in classAbstractBuilder<EnumBuilder>
- Returns:
- this.
-
generateFileContent
Description copied from class:AbstractBuilder
Generates the complete file contents for a.java
file for the currently uncommitted class.- Specified by:
generateFileContent
in classAbstractBuilder<EnumBuilder>
- Parameters:
semVer
- for the new class.- Returns:
- the file contents as a
String
.
-