- All Implemented Interfaces:
Serializable,Comparable<Version>
The Version class is immutable and thread-safe.
- Since:
- 0.1.0
- Author:
- Zafar Khaja <zafarkhaja@gmail.com>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA mutable builder for the immutableVersionclass -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<Version> Deprecated.static final Comparator<Version> A comparator that sorts versions in increment order, from lowest to highest.static final Comparator<Version> A comparator that sorts versions in (highest) precedence order. -
Method Summary
Modifier and TypeMethodDescriptionReturns thisVersion's build metadata in the form of dot-separated identifiers.intCompares versions, along with their build metadata.intCompares versions, ignoring their build metadata.intcompareWithBuildsTo(Version other) Deprecated.forRemoval since 0.10.0, usecompareTo(Version)booleanChecks if thisVersionexactly equals the specifiedVersion.static VersionforIntegers(int major) Deprecated.forRemoval since 0.10.0, useof(long)static VersionforIntegers(int major, int minor) Deprecated.forRemoval since 0.10.0, useof(long, long)static VersionforIntegers(int major, int minor, int patch) Deprecated.forRemoval since 0.10.0, useof(long, long, long)Deprecated.forRemoval since 0.10.0, usebuildMetadata()intDeprecated.forRemoval since 0.10.0, usemajorVersion()intDeprecated.forRemoval since 0.10.0, useminorVersion()Deprecated.forRemoval since 0.10.0intDeprecated.forRemoval since 0.10.0, usepatchVersion()Deprecated.forRemoval since 0.10.0, usepreReleaseVersion()booleangreaterThan(Version other) Deprecated.forRemoval since 0.10.0, useisHigherThan(Version)booleangreaterThanOrEqualTo(Version other) Deprecated.forRemoval since 0.10.0, useisHigherThanOrEquivalentTo(Version)inthashCode()Deprecated.forRemoval since 0.10.0Deprecated.forRemoval since 0.10.0, usenextMajorVersion(String...)incrementMajorVersion(String preRelease) Deprecated.forRemoval since 0.10.0, usenextMajorVersion(String...)Deprecated.forRemoval since 0.10.0, usenextMinorVersion(String...)incrementMinorVersion(String preRelease) Deprecated.forRemoval since 0.10.0, usenextMinorVersion(String...)Deprecated.forRemoval since 0.10.0, usenextPatchVersion(String...)incrementPatchVersion(String preRelease) Deprecated.forRemoval since 0.10.0, usenextPatchVersion(String...)Deprecated.forRemoval since 0.10.0, usenextPreReleaseVersion(String...)booleanisEquivalentTo(Version other) Determines if thisVersionhas the same precedence as the specifiedVersion.booleanisHigherThan(Version other) Determines if thisVersionhas a higher precedence compared with the specifiedVersion.booleanDetermines if thisVersionhas a higher or equal precedence compared with the specifiedVersion.booleanisLowerThan(Version other) Determines if thisVersionhas a lower precedence compared with the specifiedVersion.booleanisLowerThanOrEquivalentTo(Version other) Determines if thisVersionhas a lower or equal precedence compared with the specifiedVersion.booleanChecks if thisVersionrepresents a pre-release version.booleanisPublicApiCompatibleWith(Version other) Checks if thisVersionis compatible with the specifiedVersionin terms of their public API.booleanChecks if thisVersionrepresents a stable public API.booleanisSameMajorVersionAs(Version other) Checks if thisVersionis compatible with the specifiedVersionin terms of their major versions.booleanisSameMinorVersionAs(Version other) Checks if thisVersionis compatible with the specifiedVersionin terms of their major and minor versions.booleanisSamePatchVersionAs(Version other) Checks if thisVersionis compatible with the specifiedVersionin terms of their major, minor and patch versions.booleanisStable()Checks if thisVersionrepresents a stable version.static booleanChecks validity of the specified SemVer version string in strict mode, which ensures full compliance with the specification.static booleanChecks validity of the specified SemVer version string.booleanDeprecated.forRemoval since 0.10.0, useisLowerThan(Version)booleanlessThanOrEqualTo(Version other) Deprecated.forRemoval since 0.10.0, useisLowerThanOrEquivalentTo(Version)longReturns thisVersion's major version.longReturns thisVersion's minor version.nextMajorVersion(long major, String... preReleaseIds) Obtains the nextVersionof the specified major version number, with an optional pre-release version label.nextMajorVersion(String... preReleaseIds) Obtains the nextVersionby incrementing the major version number by one, with an optional pre-release version label.nextMinorVersion(long minor, String... preReleaseIds) Obtains the nextVersionof the specified minor version number, with an optional pre-release version label.nextMinorVersion(String... preReleaseIds) Obtains the nextVersionby incrementing the minor version number by one, with an optional pre-release version label.nextPatchVersion(long patch, String... preReleaseIds) Obtains the nextVersionof the specified patch version number, with an optional pre-release version label.nextPatchVersion(String... preReleaseIds) Obtains the nextVersionby incrementing the patch version number by one, with an optional pre-release version label.nextPreReleaseVersion(String... ids) Obtains the nextVersionby incrementing or replacing the pre-release version.static Versionof(long major) Obtains aVersioninstance of the specified major version.static Versionof(long major, long minor) Obtains aVersioninstance of the specified major and minor versions.static Versionof(long major, long minor, long patch) Obtains aVersioninstance of the specified major, minor and patch versions.static VersionObtains aVersioninstance of the specified major, minor, patch and pre-release versions.static VersionObtains aVersioninstance of the specified major, minor, patch and pre-release versions, as well as build metadata.static VersionObtains aVersioninstance of the specified major, minor and pre-release versions.static VersionObtains aVersioninstance of the specified major, minor and pre-release versions, as well as build metadata.static VersionObtains aVersioninstance of the specified major and pre-release versions.static VersionObtains aVersioninstance of the specified major and pre-release versions, as well as build metadata.static VersionObtains aVersioninstance by parsing the specified string in strict mode, which ensures full compliance with the specification.static VersionObtains aVersioninstance by parsing the specified string.longReturns thisVersion's patch version.Returns thisVersion's pre-release version in the form of dot-separated identifiers.booleanChecks if thisVersionsatisfies the specified range expression.booleanChecks if thisVersionsatisfies the specified predicate.setBuildMetadata(String build) Deprecated.forRemoval since 0.10.0, usewithBuildMetadata(String...)setPreReleaseVersion(String preRelease) Deprecated.forRemoval since 0.10.0, consider usingnextPreReleaseVersion(String...)Converts thisVersiontoBuilder.Obtains the nextVersionby dropping the pre-release version.toString()Tries to obtain aVersioninstance by parsing the specified string in strict mode, which ensures full compliance with the specification.Tries to obtain aVersioninstance by parsing the specified string.static VersionDeprecated.forRemoval since 0.10.0, useparse(String)withBuildMetadata(String... ids) Obtains a newVersionwith the specified build identifiers.Obtains a (new)Versionwithout build metadata.
-
Field Details
-
INCREMENT_ORDER
A comparator that sorts versions in increment order, from lowest to highest.The comparator is intended for use in comparison-based data structures.
- Since:
- 0.10.0
- See Also:
-
PRECEDENCE_ORDER
A comparator that sorts versions in (highest) precedence order.The ordering imposed by this comparator is reverse of the "natural" increment ordering, that is, versions are arranged in descending order from highest-precedence to lowest-precedence.
The comparator is intended for use in comparison-based data structures.
- Since:
- 0.10.0
- See Also:
-
BUILD_AWARE_ORDER
Deprecated.forRemoval since 0.10.0, usecompareTo(Version)
-
-
Method Details
-
parse
Obtains aVersioninstance by parsing the specified string in strict mode, which ensures full compliance with the specification.- Parameters:
version- a string representing a SemVer version, non-null- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifversionis nullParseException- ifversioncan't be parsed- Since:
- 0.10.0
- See Also:
-
parse
Obtains aVersioninstance by parsing the specified string.This method provides a way to parse the specified string in lenient mode, which accepts shorter version cores, such as "1" or "1.2".
- Parameters:
version- a string representing a SemVer version, non-nullstrictly- whether to parse the specified string in strict mode- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifversionis nullParseException- ifversioncan't be parsed- Since:
- 0.10.0
- See Also:
-
tryParse
Tries to obtain aVersioninstance by parsing the specified string in strict mode, which ensures full compliance with the specification.- Parameters:
version- a string representing a SemVer version, nullable- Returns:
- an
Optionalwith aVersioninstance, if the specified string can be parsed; emptyOptionalotherwise - Since:
- 0.10.0
- See Also:
-
tryParse
Tries to obtain aVersioninstance by parsing the specified string.This method provides a way to parse the specified string in lenient mode, which accepts shorter version cores, such as "1" or "1.2".
- Parameters:
version- a string representing a SemVer version, nullablestrictly- whether to parse the specified string in strict mode- Returns:
- an
Optionalwith aVersioninstance, if the specified string can be parsed; emptyOptionalotherwise - Since:
- 0.10.0
- See Also:
-
isValid
Checks validity of the specified SemVer version string in strict mode, which ensures full compliance with the specification.Note that internally this method makes use of
parse(String)and suppresses any exceptions, so using it to avoid dealing with exceptions like so:
would mean parsing the same version string twice. In this case, as an alternative, consider usingString version = "1.2.3"; if (Version.isValid(version)) { Version v = Version.parse(version); }tryParse(String).- Parameters:
version- a string representing a SemVer version, nullable- Returns:
true, if the specified string is a valid SemVer version;falseotherwise- Since:
- 0.10.0
- See Also:
-
isValid
Checks validity of the specified SemVer version string.This method provides a way to parse the specified string in lenient mode, which accepts shorter version cores, such as "1" or "1.2".
- Parameters:
version- a string representing a SemVer version, nullablestrictly- whether to parse the specified string in strict mode- Returns:
true, if the specified string is a valid SemVer version;falseotherwise- Since:
- 0.10.0
- See Also:
-
of
Obtains aVersioninstance of the specified major version.- Parameters:
major- a major version number, non-negative- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifmajoris negative- Since:
- 0.10.0
-
of
Obtains aVersioninstance of the specified major and pre-release versions.- Parameters:
major- a major version number, non-negativepreRelease- a pre-release version label, nullable- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifmajoris negativeParseException- ifpreReleasecan't be parsed- Since:
- 0.10.0
-
of
Obtains aVersioninstance of the specified major and pre-release versions, as well as build metadata.- Parameters:
major- a major version number, non-negativepreRelease- a pre-release version label, nullablebuild- a build metadata label, nullable- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifmajoris negativeParseException- ifpreReleaseorbuildcan't be parsed- Since:
- 0.10.0
-
of
Obtains aVersioninstance of the specified major and minor versions.- Parameters:
major- a major version number, non-negativeminor- a minor version number, non-negative- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifmajororminoris negative- Since:
- 0.10.0
-
of
Obtains aVersioninstance of the specified major, minor and pre-release versions.- Parameters:
major- a major version number, non-negativeminor- a minor version number, non-negativepreRelease- a pre-release version label, nullable- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifmajororminoris negativeParseException- ifpreReleasecan't be parsed- Since:
- 0.10.0
-
of
Obtains aVersioninstance of the specified major, minor and pre-release versions, as well as build metadata.- Parameters:
major- a major version number, non-negativeminor- a minor version number, non-negativepreRelease- a pre-release version label, nullablebuild- a build metadata label, nullable- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifmajororminoris negativeParseException- ifpreReleaseorbuildcan't be parsed- Since:
- 0.10.0
-
of
Obtains aVersioninstance of the specified 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:
- a
Versioninstance - Throws:
IllegalArgumentException- if any of the arguments is negative- Since:
- 0.10.0
-
of
Obtains aVersioninstance of the specified major, minor, patch and pre-release versions.- Parameters:
major- a major version number, non-negativeminor- a minor version number, non-negativepatch- a patch version number, non-negativepreRelease- a pre-release version label, nullable- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- if any of the numeric arguments is negativeParseException- ifpreReleasecan't be parsed- Since:
- 0.10.0
-
of
Obtains aVersioninstance of the specified major, minor, patch and pre-release versions, as well as build metadata.- Parameters:
major- a major version number, non-negativeminor- a minor version number, non-negativepatch- a patch version number, non-negativepreRelease- a pre-release version label, nullablebuild- a build metadata label, nullable- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- if any of the numeric arguments is negativeParseException- ifpreReleaseorbuildcan't be parsed- Since:
- 0.10.0
-
majorVersion
public long majorVersion()Returns thisVersion's major version.- Returns:
- the major version number
- Since:
- 0.10.0
-
minorVersion
public long minorVersion()Returns thisVersion's minor version.- Returns:
- the minor version number
- Since:
- 0.10.0
-
patchVersion
public long patchVersion()Returns thisVersion's patch version.- Returns:
- the patch version number
- Since:
- 0.10.0
-
preReleaseVersion
Returns thisVersion's pre-release version in the form of dot-separated identifiers.- Returns:
- the pre-release version label, if present
- Since:
- 0.10.0
-
buildMetadata
Returns thisVersion's build metadata in the form of dot-separated identifiers.- Returns:
- the build metadata label, if present
- Since:
- 0.10.0
-
nextMajorVersion
Obtains the nextVersionby incrementing the major version number by one, with an optional pre-release version label.Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
This method drops the build metadata, if present.
- Parameters:
preReleaseIds- zero or more pre-release identifiers, non-null- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the major version number overflowsIllegalArgumentException- ifpreReleaseIdsis null or contains nullParseException- if any of the specified identifiers can't be parsed- Since:
- 0.10.0
-
nextMajorVersion
Obtains the nextVersionof the specified major version number, with an optional pre-release version label.The specified major version number must be higher than this
Version's major version.Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
This method drops the build metadata, if present.
- Parameters:
major- the next major version number, non-negativepreReleaseIds- zero or more pre-release identifiers, non-null- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifmajoris negative, or ifpreReleaseIdsis null or contains nullIllegalStateException- ifmajoris lower than or equivalent to thisVersion's major versionParseException- if any of the specified identifiers can't be parsed- Since:
- 0.10.0
-
nextMinorVersion
Obtains the nextVersionby incrementing the minor version number by one, with an optional pre-release version label.Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
This method drops the build metadata, if present.
- Parameters:
preReleaseIds- zero or more pre-release identifiers, non-null- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the minor version number overflowsIllegalArgumentException- ifpreReleaseIdsis null or contains nullParseException- if any of the specified identifiers can't be parsed- Since:
- 0.10.0
-
nextMinorVersion
Obtains the nextVersionof the specified minor version number, with an optional pre-release version label.The specified minor version number must be higher than this
Version's minor version.Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
This method drops the build metadata, if present.
- Parameters:
minor- the next minor version number, non-negativepreReleaseIds- zero or more pre-release identifiers, non-null- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifminoris negative, or ifpreReleaseIdsis null or contains nullIllegalStateException- ifminoris lower than or equivalent to thisVersion's minor versionParseException- if any of the specified identifiers can't be parsed- Since:
- 0.10.0
-
nextPatchVersion
Obtains the nextVersionby incrementing the patch version number by one, with an optional pre-release version label.Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
This method drops the build metadata, if present.
- Parameters:
preReleaseIds- zero or more pre-release identifiers, non-null- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the patch version number overflowsIllegalArgumentException- ifpreReleaseIdsis null or contains nullParseException- if any of the specified identifiers can't be parsed- Since:
- 0.10.0
-
nextPatchVersion
Obtains the nextVersionof the specified patch version number, with an optional pre-release version label.The specified patch version number must be higher than this
Version's patch version.Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
This method drops the build metadata, if present.
- Parameters:
patch- the next patch version number, non-negativepreReleaseIds- zero or more pre-release identifiers, non-null- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifpatchis negative, or ifpreReleaseIdsis null or contains nullIllegalStateException- ifpatchis lower than or equivalent to thisVersion's patch versionParseException- if any of the specified identifiers can't be parsed- Since:
- 0.10.0
-
nextPreReleaseVersion
Obtains the nextVersionby incrementing or replacing the pre-release version.If no pre-release identifiers are specified, the current pre-release version's last numeric identifier is incremented. If the current pre-release version's last identifier is not numeric, a new numeric identifier of value "0" is appended for this operation. If specified, however, the pre-release identifiers replace the current pre-release version. The new pre-release version must be higher than this
Version's pre-release version.Multiple identifiers can be specified in a single argument joined with dots, or in separate arguments, or both.
This method drops the build metadata, if present.
- Parameters:
ids- zero or more pre-release identifiers, non-null- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the incremented numeric identifier overflowsIllegalArgumentException- ifidsis null or contains nullIllegalStateException- if invoked on a stableVersion, or if the specified pre-release version is lower than or equivalent to thisVersion's pre-release versionParseException- if any of the specified identifiers can't be parsed- Since:
- 0.10.0
-
toStableVersion
Obtains the nextVersionby dropping the pre-release version.This method drops the build metadata, if present.
- Returns:
- a
Versioninstance - Since:
- 0.10.0
-
withBuildMetadata
Obtains a newVersionwith the specified build identifiers.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:
- a
Versioninstance - Throws:
IllegalArgumentException- ifidsis null/empty or contains nullParseException- if any of the specified identifiers can't be parsed- Since:
- 0.10.0
-
withoutBuildMetadata
Obtains a (new)Versionwithout build metadata.- Returns:
- a
Versioninstance - Since:
- 0.10.0
-
satisfies
Checks if thisVersionsatisfies the specified predicate.- Parameters:
predicate- a predicate to test, non-null- Returns:
true, if thisVersionsatisfies the predicate;falseotherwise- Throws:
IllegalArgumentException- ifpredicateis null- Since:
- 0.10.0
-
satisfies
Checks if thisVersionsatisfies the specified range expression.- Parameters:
expr- a SemVer Expression string, non-null- Returns:
true, if thisVersionsatisfies the specified expression;falseotherwise- Throws:
IllegalArgumentException- ifexpris nullParseException- ifexprcan't be parsed- Since:
- 0.7.0
-
isPreRelease
public boolean isPreRelease()Checks if thisVersionrepresents a pre-release version.This method is opposite of
isStable().- Returns:
true, if thisVersionrepresents a pre-release version;falseotherwise- Since:
- 0.10.0
- See Also:
-
isStable
public boolean isStable()Checks if thisVersionrepresents a stable version.Pre-release versions are considered unstable. (SemVer p.9)
- Returns:
true, if thisVersionrepresents a stable version;falseotherwise- Since:
- 0.10.0
- See Also:
-
isPublicApiStable
public boolean isPublicApiStable()Checks if thisVersionrepresents a stable public API.Versions lower than 1.0.0 are for initial development, therefore the public API should not be considered stable. (SemVer p.4)
- Returns:
true, if thisVersionrepresents a stable public API;falseotherwise- Since:
- 0.10.0
-
isPublicApiCompatibleWith
Checks if thisVersionis compatible with the specifiedVersionin terms of their public API.Two versions are compatible in terms of public API iff they have the same major version of 1 or higher. Being public API compatible doesn't necessarily mean both versions have the same set of public API units. It only means that the versions are interchangeable.
- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if the versions are compatible in terms of public API;falseotherwise- Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
-
isSameMajorVersionAs
Checks if thisVersionis compatible with the specifiedVersionin terms of their major versions.- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if both versions have the same major version;falseotherwise- Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
-
isSameMinorVersionAs
Checks if thisVersionis compatible with the specifiedVersionin terms of their major and minor versions.- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if both versions have the same major and minor versions;falseotherwise- Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
-
isSamePatchVersionAs
Checks if thisVersionis compatible with the specifiedVersionin terms of their major, minor and patch versions.- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if both versions have the same major, minor and patch versions;falseotherwise- Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
-
isHigherThan
Determines if thisVersionhas a higher precedence compared with the specifiedVersion.- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if thisVersionis higher than the otherVersion;falseotherwise- Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
- See Also:
-
isHigherThanOrEquivalentTo
Determines if thisVersionhas a higher or equal precedence compared with the specifiedVersion.- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if thisVersionis higher than or equivalent to the otherVersion;falseotherwise- Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
- See Also:
-
isLowerThan
Determines if thisVersionhas a lower precedence compared with the specifiedVersion.- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if thisVersionis lower than the otherVersion;falseotherwise- Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
- See Also:
-
isLowerThanOrEquivalentTo
Determines if thisVersionhas a lower or equal precedence compared with the specifiedVersion.- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if thisVersionis lower than or equivalent to the otherVersion;falseotherwise- Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
- See Also:
-
isEquivalentTo
Determines if thisVersionhas the same precedence as the specifiedVersion.As per SemVer p.10, build metadata is ignored when determining version precedence. To test for exact equality, including build metadata, use
equals(Object).- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if thisVersionis equivalent to the otherVersion;falseotherwise- Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
- See Also:
-
compareTo
Compares versions, along with their build metadata.Note that this method violates the SemVer p.10 ("build metadata must be ignored") rule, hence can't be used for determining version precedence. It was made so intentionally for it to be consistent with
equalsas defined byComparable, and to be used in comparison-based data structures.As the Specification defines no comparison rules for build metadata, this behavior is strictly implementation-defined. Build metadata are compared similarly to pre-release versions. A version with build metadata is ordered after an equivalent one without it.
To compare Versions without their build metadata in order to determine precedence use
compareToIgnoreBuildMetadata(Version).- Specified by:
compareToin interfaceComparable<Version>- Parameters:
other- theVersionto compare with, non-null- Returns:
- a negative integer, zero or a positive integer if this
Versionis less than, equal to or greater than the specifiedVersion - Throws:
IllegalArgumentException- ifotheris null
-
compareToIgnoreBuildMetadata
Compares versions, ignoring their build metadata.This method adheres to the comparison rules defined by the Specification, and as such can be used for determining version precedence, either as a natural-order comparator (
Version::compareToIgnoreBuildMetadata), or as a regular method.- Parameters:
other- theVersionto compare with, non-null- Returns:
- a negative integer, zero or a positive integer if this
Versionis lower than, equivalent to or higher than the specifiedVersion - Throws:
IllegalArgumentException- ifotheris null- Since:
- 0.10.0
-
equals
Checks if thisVersionexactly equals the specifiedVersion.Although primarily intended for use in hash-based data structures, it can be used for testing for exact equality, including build metadata, if needed. To test for equivalence use
isEquivalentTo(Version). -
hashCode
public int hashCode() -
toString
-
toBuilder
Converts thisVersiontoBuilder.This method allows to use an instance of
Versionas a template for new instances.- Returns:
- a
Builderinstance populated with values from thisVersion - Since:
- 0.10.0
-
valueOf
Deprecated.forRemoval since 0.10.0, useparse(String)- Parameters:
version- a string representing a SemVer version, non-null- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifversionis nullParseException- ifversioncan't be parsed
-
forIntegers
Deprecated.forRemoval since 0.10.0, useof(long)- Parameters:
major- a major version number, non-negative- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifmajoris negative
-
forIntegers
Deprecated.forRemoval since 0.10.0, useof(long, long)- Parameters:
major- a major version number, non-negativeminor- a minor version number, non-negative- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifmajororminoris negative
-
forIntegers
Deprecated.forRemoval since 0.10.0, useof(long, long, long)- Parameters:
major- a major version number, non-negativeminor- a minor version number, non-negativepatch- a patch version number, non-negative- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- if any of the arguments is negative
-
getNormalVersion
Deprecated.forRemoval since 0.10.0- Returns:
- the version core of this
Version
-
getMajorVersion
Deprecated.forRemoval since 0.10.0, usemajorVersion()- Returns:
- the major version number
-
getMinorVersion
Deprecated.forRemoval since 0.10.0, useminorVersion()- Returns:
- the minor version number
-
getPatchVersion
Deprecated.forRemoval since 0.10.0, usepatchVersion()- Returns:
- the patch version number
-
getPreReleaseVersion
Deprecated.forRemoval since 0.10.0, usepreReleaseVersion()- Returns:
- the pre-release version label, if present; empty string otherwise
-
getBuildMetadata
Deprecated.forRemoval since 0.10.0, usebuildMetadata()- Returns:
- the build metadata label, if present; empty string otherwise
-
setPreReleaseVersion
Deprecated.forRemoval since 0.10.0, consider usingnextPreReleaseVersion(String...)- Parameters:
preRelease- the pre-release version label, non-null- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifpreReleaseis nullParseException- ifpreReleasecan't be parsed
-
setBuildMetadata
Deprecated.forRemoval since 0.10.0, usewithBuildMetadata(String...)- Parameters:
build- the build metadata label, non-null- Returns:
- a
Versioninstance - Throws:
IllegalArgumentException- ifbuildis nullParseException- ifbuildcan't be parsed
-
incrementMajorVersion
Deprecated.forRemoval since 0.10.0, usenextMajorVersion(String...)- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the major version number overflows
-
incrementMajorVersion
Deprecated.forRemoval since 0.10.0, usenextMajorVersion(String...)- Parameters:
preRelease- the pre-release version label, non-null- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the major version number overflowsIllegalArgumentException- ifpreReleaseis nullParseException- ifpreReleasecan't be parsed
-
incrementMinorVersion
Deprecated.forRemoval since 0.10.0, usenextMinorVersion(String...)- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the minor version number overflows
-
incrementMinorVersion
Deprecated.forRemoval since 0.10.0, usenextMinorVersion(String...)- Parameters:
preRelease- the pre-release version label, non-null- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the minor version number overflowsIllegalArgumentException- ifpreReleaseis nullParseException- ifpreReleasecan't be parsed
-
incrementPatchVersion
Deprecated.forRemoval since 0.10.0, usenextPatchVersion(String...)- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the patch version number overflows
-
incrementPatchVersion
Deprecated.forRemoval since 0.10.0, usenextPatchVersion(String...)- Parameters:
preRelease- the pre-release version label, non-null- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the patch version number overflowsIllegalArgumentException- ifpreReleaseis nullParseException- ifpreReleasecan't be parsed
-
incrementPreReleaseVersion
Deprecated.forRemoval since 0.10.0, usenextPreReleaseVersion(String...)- Returns:
- a
Versioninstance - Throws:
ArithmeticException- if the incremented numeric identifier overflowsIllegalStateException- if invoked on a stableVersion
-
incrementBuildMetadata
Deprecated.forRemoval since 0.10.0- Returns:
- a
Versioninstance - Throws:
IllegalStateException- if thisVersiondoesn't have build metadata
-
greaterThan
Deprecated.forRemoval since 0.10.0, useisHigherThan(Version)- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if thisVersionis higher than the otherVersion;falseotherwise- Throws:
IllegalArgumentException- ifotheris null
-
greaterThanOrEqualTo
Deprecated.forRemoval since 0.10.0, useisHigherThanOrEquivalentTo(Version)- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if thisVersionis higher than or equivalent to the otherVersion;falseotherwise- Throws:
IllegalArgumentException- ifotheris null
-
lessThan
Deprecated.forRemoval since 0.10.0, useisLowerThan(Version)- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if thisVersionis lower than the otherVersion;falseotherwise- Throws:
IllegalArgumentException- ifotheris null
-
lessThanOrEqualTo
Deprecated.forRemoval since 0.10.0, useisLowerThanOrEquivalentTo(Version)- Parameters:
other- theVersionto compare with, non-null- Returns:
true, if thisVersionis lower than or equivalent to the otherVersion;falseotherwise- Throws:
IllegalArgumentException- ifotheris null
-
compareWithBuildsTo
Deprecated.forRemoval since 0.10.0, usecompareTo(Version)- Parameters:
other- theVersionto compare with, non-null- Returns:
- a negative integer, zero or a positive integer if this
Versionis less than, equal to or greater than the specifiedVersion - Throws:
IllegalArgumentException- ifotheris null
-
compareTo(Version)