java.lang.Object
com.github.zafarkhaja.semver.Version.Builder
- Enclosing class:
Version
A mutable builder for the immutable
Version class-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddBuildIdentifiers(String... ids) Appends (additional) build identifier(s).addPreReleaseIdentifiers(String... ids) Appends (additional) pre-release identifier(s).build()Obtains aVersioninstance with previously set values.setBuildMetadata(String... ids) Sets the build metadata.setMajorVersion(long major) Sets the major version.setMinorVersion(long minor) Sets the minor version.setNormalVersion(String normal) Deprecated.forRemoval since 0.10.0setPatchVersion(long patch) Sets the patch version.setPreReleaseVersion(String... ids) Sets the pre-release version.setVersionCore(long major) Sets the major version; the minor and patch versions are assigned 0.setVersionCore(long major, long minor) Sets the major and minor versions; the patch version is assigned 0.setVersionCore(long major, long minor, long patch) Sets major, minor and patch versions.Unsets the build metadata.Unsets the pre-release version.
-
Constructor Details
-
Builder
public Builder()Default constructor, initializes fields with default values (0.0.0) -
Builder
Deprecated.forRemoval since 0.10.0- Parameters:
normal- a string representing a normal version, non-null- Throws:
IllegalArgumentException- if (@code normal) is null
-
-
Method Details
-
setVersionCore
Sets the major version; the minor and patch versions are assigned 0.- Parameters:
major- a major version number, non-negative- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- ifmajoris negative- Since:
- 0.10.0
-
setVersionCore
Sets the major and minor versions; the patch version is assigned 0.- Parameters:
major- a major version number, non-negativeminor- a minor version number, non-negative- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- if any of the arguments is negative- Since:
- 0.10.0
-
setVersionCore
Sets major, minor and patch versions.- Parameters:
major- a major version number, non-negativeminor- a minor version number, non-negativepatch- a patch version number, non-negative- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- if any of the arguments is negative- Since:
- 0.10.0
-
setMajorVersion
Sets the major version.- Parameters:
major- a major version number, non-negative- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- ifmajoris negative- Since:
- 0.10.0
-
setMinorVersion
Sets the minor version.- Parameters:
minor- a minor version number, non-negative- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- ifminoris negative- Since:
- 0.10.0
-
setPatchVersion
Sets the patch version.- Parameters:
patch- a patch version number, non-negative- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- ifpatchis negative- Since:
- 0.10.0
-
setPreReleaseVersion
Sets the pre-release version.Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
- Parameters:
ids- one or more pre-release identifiers, non-null- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- ifidsis null/empty or contains null
-
addPreReleaseIdentifiers
Appends (additional) pre-release identifier(s).If no pre-release identifiers have been previously set, the method works as
setPreReleaseVersion(String...).Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
- Parameters:
ids- one or more pre-release identifiers, non-null- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- ifidsis null/empty or contains null- Since:
- 0.10.0
- See Also:
-
unsetPreReleaseVersion
Unsets the pre-release version.- Returns:
- this
Builderinstance - Since:
- 0.10.0
-
setBuildMetadata
Sets the build metadata.Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
- Parameters:
ids- one or more build identifiers, non-null- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- ifidsis null/empty or contains null
-
addBuildIdentifiers
Appends (additional) build identifier(s).If no build identifiers have been previously set, the method works as
setBuildMetadata(String...).Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
- Parameters:
ids- one or more build identifiers, non-null- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- ifidsis null/empty or contains null- Since:
- 0.10.0
- See Also:
-
unsetBuildMetadata
Unsets the build metadata.- Returns:
- this
Builderinstance - Since:
- 0.10.0
-
build
Obtains aVersioninstance with previously set values.- Returns:
- a
Versioninstance - Throws:
ParseException- if any of the previously set identifiers can't be parsed- See Also:
-
setNormalVersion
Deprecated.forRemoval since 0.10.0- Parameters:
normal- a string representing a normal version, non-null- Returns:
- this
Builderinstance - Throws:
IllegalArgumentException- if (@code normal) is null
-