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 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 StringGenerates 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.protected voidValidates additionalPredicates for determining the validity of the currently uncommitted class.Methods inherited from class io.github.chrimle.classforge.AbstractBuilder
commit, determineSemVerChange, generateClassFile, resolveEffectivePackageName, resolveFullyQualifiedClassName, setVersionPlacement, updateClassName, updateDirectory, updatePackageName
-
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
Adds theenumConstantNamesto the currently uncommitted enum class.- Parameters:
enumConstantNames- to add.- Returns:
- this Builder.
- Throws:
IllegalArgumentException- ifenumConstantNamesisnull, empty, or containsStrings which arenull, does not match the RegEx "^([A-Za-z]|(_+[A-Za-z0-9]))[A-Z_a-z0-9]*$" or the currently uncommitted class already has an enum constant with the same name.- Since:
- 0.3.0
-
removeEnumConstants
Removes theenumConstantNamesfrom the currently uncommitted enum class.- Parameters:
enumConstantNames- to remove.- Returns:
- this Builder.
- Throws:
IllegalArgumentException- ifenumConstantNamesisnull, empty, or containsStrings which arenull, does not match the RegEx "^([A-Za-z]|(_+[A-Za-z0-9]))[A-Z_a-z0-9]*$" or the currently uncommitted class does not have the enum constant to be removed.- Since:
- 0.3.0
-
self
Description copied from class:AbstractBuilderReturns this asAbstractBuilder.- Specified by:
selfin classAbstractBuilder<EnumBuilder>- Returns:
- this.
-
validateAdditionalPredicates
protected void validateAdditionalPredicates()Description copied from class:AbstractBuilderValidates additionalPredicates for determining the validity of the currently uncommitted class.- Specified by:
validateAdditionalPredicatesin classAbstractBuilder<EnumBuilder>
-
generateFileContent
Description copied from class:AbstractBuilderGenerates the complete file contents for a.javafile for the currently uncommitted class.- Specified by:
generateFileContentin classAbstractBuilder<EnumBuilder>- Returns:
- the file contents as a
String.
-