java.lang.Object
com.github.zafarkhaja.semver.Version
All Implemented Interfaces:
Serializable, Comparable<Version>

public class Version extends Object implements Comparable<Version>, Serializable
A representation of version as defined by the SemVer Specification.

The Version class is immutable and thread-safe.

Since:
0.1.0
Author:
Zafar Khaja <zafarkhaja@gmail.com>
See Also:
  • Field Details

    • INCREMENT_ORDER

      public static final Comparator<Version> 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

      public static final Comparator<Version> 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 public static final Comparator<Version> BUILD_AWARE_ORDER
      Deprecated.
      forRemoval since 0.10.0, use compareTo(Version)
  • Method Details

    • parse

      public static Version parse(String version)
      Obtains a Version instance 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 Version instance
      Throws:
      IllegalArgumentException - if version is null
      ParseException - if version can't be parsed
      Since:
      0.10.0
      See Also:
    • parse

      public static Version parse(String version, boolean strictly)
      Obtains a Version instance 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-null
      strictly - whether to parse the specified string in strict mode
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if version is null
      ParseException - if version can't be parsed
      Since:
      0.10.0
      See Also:
    • tryParse

      public static Optional<Version> tryParse(String version)
      Tries to obtain a Version instance 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 Optional with a Version instance, if the specified string can be parsed; empty Optional otherwise
      Since:
      0.10.0
      See Also:
    • tryParse

      public static Optional<Version> tryParse(String version, boolean strictly)
      Tries to obtain a Version instance 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, nullable
      strictly - whether to parse the specified string in strict mode
      Returns:
      an Optional with a Version instance, if the specified string can be parsed; empty Optional otherwise
      Since:
      0.10.0
      See Also:
    • isValid

      public static boolean isValid(String version)
      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:

      
         String version = "1.2.3";
         if (Version.isValid(version)) {
           Version v = Version.parse(version);
         }
       
      would mean parsing the same version string twice. In this case, as an alternative, consider using tryParse(String).
      Parameters:
      version - a string representing a SemVer version, nullable
      Returns:
      true, if the specified string is a valid SemVer version; false otherwise
      Since:
      0.10.0
      See Also:
    • isValid

      public static boolean isValid(String version, boolean strictly)
      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, nullable
      strictly - whether to parse the specified string in strict mode
      Returns:
      true, if the specified string is a valid SemVer version; false otherwise
      Since:
      0.10.0
      See Also:
    • of

      public static Version of(long major)
      Obtains a Version instance of the specified major version.
      Parameters:
      major - a major version number, non-negative
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if major is negative
      Since:
      0.10.0
    • of

      public static Version of(long major, String preRelease)
      Obtains a Version instance of the specified major and pre-release versions.
      Parameters:
      major - a major version number, non-negative
      preRelease - a pre-release version label, nullable
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if major is negative
      ParseException - if preRelease can't be parsed
      Since:
      0.10.0
    • of

      public static Version of(long major, String preRelease, String build)
      Obtains a Version instance of the specified major and pre-release versions, as well as build metadata.
      Parameters:
      major - a major version number, non-negative
      preRelease - a pre-release version label, nullable
      build - a build metadata label, nullable
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if major is negative
      ParseException - if preRelease or build can't be parsed
      Since:
      0.10.0
    • of

      public static Version of(long major, long minor)
      Obtains a Version instance of the specified major and minor versions.
      Parameters:
      major - a major version number, non-negative
      minor - a minor version number, non-negative
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if major or minor is negative
      Since:
      0.10.0
    • of

      public static Version of(long major, long minor, String preRelease)
      Obtains a Version instance of the specified major, minor and pre-release versions.
      Parameters:
      major - a major version number, non-negative
      minor - a minor version number, non-negative
      preRelease - a pre-release version label, nullable
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if major or minor is negative
      ParseException - if preRelease can't be parsed
      Since:
      0.10.0
    • of

      public static Version of(long major, long minor, String preRelease, String build)
      Obtains a Version instance of the specified major, minor and pre-release versions, as well as build metadata.
      Parameters:
      major - a major version number, non-negative
      minor - a minor version number, non-negative
      preRelease - a pre-release version label, nullable
      build - a build metadata label, nullable
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if major or minor is negative
      ParseException - if preRelease or build can't be parsed
      Since:
      0.10.0
    • of

      public static Version of(long major, long minor, long patch)
      Obtains a Version instance of the specified major, minor and patch versions.
      Parameters:
      major - a major version number, non-negative
      minor - a minor version number, non-negative
      patch - a patch version number, non-negative
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if any of the arguments is negative
      Since:
      0.10.0
    • of

      public static Version of(long major, long minor, long patch, String preRelease)
      Obtains a Version instance of the specified major, minor, patch and pre-release versions.
      Parameters:
      major - a major version number, non-negative
      minor - a minor version number, non-negative
      patch - a patch version number, non-negative
      preRelease - a pre-release version label, nullable
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if any of the numeric arguments is negative
      ParseException - if preRelease can't be parsed
      Since:
      0.10.0
    • of

      public static Version of(long major, long minor, long patch, String preRelease, String build)
      Obtains a Version instance of the specified major, minor, patch and pre-release versions, as well as build metadata.
      Parameters:
      major - a major version number, non-negative
      minor - a minor version number, non-negative
      patch - a patch version number, non-negative
      preRelease - a pre-release version label, nullable
      build - a build metadata label, nullable
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if any of the numeric arguments is negative
      ParseException - if preRelease or build can't be parsed
      Since:
      0.10.0
    • majorVersion

      public long majorVersion()
      Returns this Version's major version.
      Returns:
      the major version number
      Since:
      0.10.0
    • minorVersion

      public long minorVersion()
      Returns this Version's minor version.
      Returns:
      the minor version number
      Since:
      0.10.0
    • patchVersion

      public long patchVersion()
      Returns this Version's patch version.
      Returns:
      the patch version number
      Since:
      0.10.0
    • preReleaseVersion

      public Optional<String> preReleaseVersion()
      Returns this Version's pre-release version in the form of dot-separated identifiers.
      Returns:
      the pre-release version label, if present
      Since:
      0.10.0
    • buildMetadata

      public Optional<String> buildMetadata()
      Returns this Version's build metadata in the form of dot-separated identifiers.
      Returns:
      the build metadata label, if present
      Since:
      0.10.0
    • nextMajorVersion

      public Version nextMajorVersion(String... preReleaseIds)
      Obtains the next Version by 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 Version instance
      Throws:
      ArithmeticException - if the major version number overflows
      IllegalArgumentException - if preReleaseIds is null or contains null
      ParseException - if any of the specified identifiers can't be parsed
      Since:
      0.10.0
    • nextMajorVersion

      public Version nextMajorVersion(long major, String... preReleaseIds)
      Obtains the next Version of 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-negative
      preReleaseIds - zero or more pre-release identifiers, non-null
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if major is negative, or if preReleaseIds is null or contains null
      IllegalStateException - if major is lower than or equivalent to this Version's major version
      ParseException - if any of the specified identifiers can't be parsed
      Since:
      0.10.0
    • nextMinorVersion

      public Version nextMinorVersion(String... preReleaseIds)
      Obtains the next Version by 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 Version instance
      Throws:
      ArithmeticException - if the minor version number overflows
      IllegalArgumentException - if preReleaseIds is null or contains null
      ParseException - if any of the specified identifiers can't be parsed
      Since:
      0.10.0
    • nextMinorVersion

      public Version nextMinorVersion(long minor, String... preReleaseIds)
      Obtains the next Version of 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-negative
      preReleaseIds - zero or more pre-release identifiers, non-null
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if minor is negative, or if preReleaseIds is null or contains null
      IllegalStateException - if minor is lower than or equivalent to this Version's minor version
      ParseException - if any of the specified identifiers can't be parsed
      Since:
      0.10.0
    • nextPatchVersion

      public Version nextPatchVersion(String... preReleaseIds)
      Obtains the next Version by 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 Version instance
      Throws:
      ArithmeticException - if the patch version number overflows
      IllegalArgumentException - if preReleaseIds is null or contains null
      ParseException - if any of the specified identifiers can't be parsed
      Since:
      0.10.0
    • nextPatchVersion

      public Version nextPatchVersion(long patch, String... preReleaseIds)
      Obtains the next Version of 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-negative
      preReleaseIds - zero or more pre-release identifiers, non-null
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if patch is negative, or if preReleaseIds is null or contains null
      IllegalStateException - if patch is lower than or equivalent to this Version's patch version
      ParseException - if any of the specified identifiers can't be parsed
      Since:
      0.10.0
    • nextPreReleaseVersion

      public Version nextPreReleaseVersion(String... ids)
      Obtains the next Version by 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 Version instance
      Throws:
      ArithmeticException - if the incremented numeric identifier overflows
      IllegalArgumentException - if ids is null or contains null
      IllegalStateException - if invoked on a stable Version, or if the specified pre-release version is lower than or equivalent to this Version's pre-release version
      ParseException - if any of the specified identifiers can't be parsed
      Since:
      0.10.0
    • toStableVersion

      public Version toStableVersion()
      Obtains the next Version by dropping the pre-release version.

      This method drops the build metadata, if present.

      Returns:
      a Version instance
      Since:
      0.10.0
    • withBuildMetadata

      public Version withBuildMetadata(String... ids)
      Obtains a new Version with 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 Version instance
      Throws:
      IllegalArgumentException - if ids is null/empty or contains null
      ParseException - if any of the specified identifiers can't be parsed
      Since:
      0.10.0
    • withoutBuildMetadata

      public Version withoutBuildMetadata()
      Obtains a (new) Version without build metadata.
      Returns:
      a Version instance
      Since:
      0.10.0
    • satisfies

      public boolean satisfies(Predicate<Version> predicate)
      Checks if this Version satisfies the specified predicate.
      Parameters:
      predicate - a predicate to test, non-null
      Returns:
      true, if this Version satisfies the predicate; false otherwise
      Throws:
      IllegalArgumentException - if predicate is null
      Since:
      0.10.0
    • satisfies

      public boolean satisfies(String expr)
      Checks if this Version satisfies the specified range expression.
      Parameters:
      expr - a SemVer Expression string, non-null
      Returns:
      true, if this Version satisfies the specified expression; false otherwise
      Throws:
      IllegalArgumentException - if expr is null
      ParseException - if expr can't be parsed
      Since:
      0.7.0
    • isPreRelease

      public boolean isPreRelease()
      Checks if this Version represents a pre-release version.

      This method is opposite of isStable().

      Returns:
      true, if this Version represents a pre-release version; false otherwise
      Since:
      0.10.0
      See Also:
    • isStable

      public boolean isStable()
      Checks if this Version represents a stable version.

      Pre-release versions are considered unstable. (SemVer p.9)

      Returns:
      true, if this Version represents a stable version; false otherwise
      Since:
      0.10.0
      See Also:
    • isPublicApiStable

      public boolean isPublicApiStable()
      Checks if this Version represents 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 this Version represents a stable public API; false otherwise
      Since:
      0.10.0
    • isPublicApiCompatibleWith

      public boolean isPublicApiCompatibleWith(Version other)
      Checks if this Version is compatible with the specified Version in 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 - the Version to compare with, non-null
      Returns:
      true, if the versions are compatible in terms of public API; false otherwise
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
    • isSameMajorVersionAs

      public boolean isSameMajorVersionAs(Version other)
      Checks if this Version is compatible with the specified Version in terms of their major versions.
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if both versions have the same major version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
    • isSameMinorVersionAs

      public boolean isSameMinorVersionAs(Version other)
      Checks if this Version is compatible with the specified Version in terms of their major and minor versions.
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if both versions have the same major and minor versions; false otherwise
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
    • isSamePatchVersionAs

      public boolean isSamePatchVersionAs(Version other)
      Checks if this Version is compatible with the specified Version in terms of their major, minor and patch versions.
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if both versions have the same major, minor and patch versions; false otherwise
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
    • isHigherThan

      public boolean isHigherThan(Version other)
      Determines if this Version has a higher precedence compared with the specified Version.
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if this Version is higher than the other Version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
      See Also:
    • isHigherThanOrEquivalentTo

      public boolean isHigherThanOrEquivalentTo(Version other)
      Determines if this Version has a higher or equal precedence compared with the specified Version.
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if this Version is higher than or equivalent to the other Version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
      See Also:
    • isLowerThan

      public boolean isLowerThan(Version other)
      Determines if this Version has a lower precedence compared with the specified Version.
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if this Version is lower than the other Version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
      See Also:
    • isLowerThanOrEquivalentTo

      public boolean isLowerThanOrEquivalentTo(Version other)
      Determines if this Version has a lower or equal precedence compared with the specified Version.
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if this Version is lower than or equivalent to the other Version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
      See Also:
    • isEquivalentTo

      public boolean isEquivalentTo(Version other)
      Determines if this Version has the same precedence as the specified Version.

      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 - the Version to compare with, non-null
      Returns:
      true, if this Version is equivalent to the other Version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
      See Also:
    • compareTo

      public int compareTo(Version other)
      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 equals as defined by Comparable, 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:
      compareTo in interface Comparable<Version>
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      a negative integer, zero or a positive integer if this Version is less than, equal to or greater than the specified Version
      Throws:
      IllegalArgumentException - if other is null
    • compareToIgnoreBuildMetadata

      public int compareToIgnoreBuildMetadata(Version other)
      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 - the Version to compare with, non-null
      Returns:
      a negative integer, zero or a positive integer if this Version is lower than, equivalent to or higher than the specified Version
      Throws:
      IllegalArgumentException - if other is null
      Since:
      0.10.0
    • equals

      public boolean equals(Object other)
      Checks if this Version exactly equals the specified Version.

      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).

      Overrides:
      equals in class Object
      Parameters:
      other - the Version to compare with, nullable
      Returns:
      true, if this Version exactly equals the other Version; false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toBuilder

      public Version.Builder toBuilder()
      Converts this Version to Builder.

      This method allows to use an instance of Version as a template for new instances.

      Returns:
      a Builder instance populated with values from this Version
      Since:
      0.10.0
    • valueOf

      @Deprecated public static Version valueOf(String version)
      Deprecated.
      forRemoval since 0.10.0, use parse(String)
      Parameters:
      version - a string representing a SemVer version, non-null
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if version is null
      ParseException - if version can't be parsed
    • forIntegers

      @Deprecated public static Version forIntegers(int major)
      Deprecated.
      forRemoval since 0.10.0, use of(long)
      Parameters:
      major - a major version number, non-negative
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if major is negative
    • forIntegers

      @Deprecated public static Version forIntegers(int major, int minor)
      Deprecated.
      forRemoval since 0.10.0, use of(long, long)
      Parameters:
      major - a major version number, non-negative
      minor - a minor version number, non-negative
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if major or minor is negative
    • forIntegers

      @Deprecated public static Version forIntegers(int major, int minor, int patch)
      Deprecated.
      forRemoval since 0.10.0, use of(long, long, long)
      Parameters:
      major - a major version number, non-negative
      minor - a minor version number, non-negative
      patch - a patch version number, non-negative
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if any of the arguments is negative
    • getNormalVersion

      @Deprecated public String getNormalVersion()
      Deprecated.
      forRemoval since 0.10.0
      Returns:
      the version core of this Version
    • getMajorVersion

      @Deprecated public int getMajorVersion()
      Deprecated.
      forRemoval since 0.10.0, use majorVersion()
      Returns:
      the major version number
    • getMinorVersion

      @Deprecated public int getMinorVersion()
      Deprecated.
      forRemoval since 0.10.0, use minorVersion()
      Returns:
      the minor version number
    • getPatchVersion

      @Deprecated public int getPatchVersion()
      Deprecated.
      forRemoval since 0.10.0, use patchVersion()
      Returns:
      the patch version number
    • getPreReleaseVersion

      @Deprecated public String getPreReleaseVersion()
      Deprecated.
      forRemoval since 0.10.0, use preReleaseVersion()
      Returns:
      the pre-release version label, if present; empty string otherwise
    • getBuildMetadata

      @Deprecated public String getBuildMetadata()
      Deprecated.
      forRemoval since 0.10.0, use buildMetadata()
      Returns:
      the build metadata label, if present; empty string otherwise
    • setPreReleaseVersion

      @Deprecated public Version setPreReleaseVersion(String preRelease)
      Deprecated.
      forRemoval since 0.10.0, consider using nextPreReleaseVersion(String...)
      Parameters:
      preRelease - the pre-release version label, non-null
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if preRelease is null
      ParseException - if preRelease can't be parsed
    • setBuildMetadata

      @Deprecated public Version setBuildMetadata(String build)
      Deprecated.
      forRemoval since 0.10.0, use withBuildMetadata(String...)
      Parameters:
      build - the build metadata label, non-null
      Returns:
      a Version instance
      Throws:
      IllegalArgumentException - if build is null
      ParseException - if build can't be parsed
    • incrementMajorVersion

      @Deprecated public Version incrementMajorVersion()
      Deprecated.
      forRemoval since 0.10.0, use nextMajorVersion(String...)
      Returns:
      a Version instance
      Throws:
      ArithmeticException - if the major version number overflows
    • incrementMajorVersion

      @Deprecated public Version incrementMajorVersion(String preRelease)
      Deprecated.
      forRemoval since 0.10.0, use nextMajorVersion(String...)
      Parameters:
      preRelease - the pre-release version label, non-null
      Returns:
      a Version instance
      Throws:
      ArithmeticException - if the major version number overflows
      IllegalArgumentException - if preRelease is null
      ParseException - if preRelease can't be parsed
    • incrementMinorVersion

      @Deprecated public Version incrementMinorVersion()
      Deprecated.
      forRemoval since 0.10.0, use nextMinorVersion(String...)
      Returns:
      a Version instance
      Throws:
      ArithmeticException - if the minor version number overflows
    • incrementMinorVersion

      @Deprecated public Version incrementMinorVersion(String preRelease)
      Deprecated.
      forRemoval since 0.10.0, use nextMinorVersion(String...)
      Parameters:
      preRelease - the pre-release version label, non-null
      Returns:
      a Version instance
      Throws:
      ArithmeticException - if the minor version number overflows
      IllegalArgumentException - if preRelease is null
      ParseException - if preRelease can't be parsed
    • incrementPatchVersion

      @Deprecated public Version incrementPatchVersion()
      Deprecated.
      forRemoval since 0.10.0, use nextPatchVersion(String...)
      Returns:
      a Version instance
      Throws:
      ArithmeticException - if the patch version number overflows
    • incrementPatchVersion

      @Deprecated public Version incrementPatchVersion(String preRelease)
      Deprecated.
      forRemoval since 0.10.0, use nextPatchVersion(String...)
      Parameters:
      preRelease - the pre-release version label, non-null
      Returns:
      a Version instance
      Throws:
      ArithmeticException - if the patch version number overflows
      IllegalArgumentException - if preRelease is null
      ParseException - if preRelease can't be parsed
    • incrementPreReleaseVersion

      @Deprecated public Version incrementPreReleaseVersion()
      Deprecated.
      forRemoval since 0.10.0, use nextPreReleaseVersion(String...)
      Returns:
      a Version instance
      Throws:
      ArithmeticException - if the incremented numeric identifier overflows
      IllegalStateException - if invoked on a stable Version
    • incrementBuildMetadata

      @Deprecated public Version incrementBuildMetadata()
      Deprecated.
      forRemoval since 0.10.0
      Returns:
      a Version instance
      Throws:
      IllegalStateException - if this Version doesn't have build metadata
    • greaterThan

      @Deprecated public boolean greaterThan(Version other)
      Deprecated.
      forRemoval since 0.10.0, use isHigherThan(Version)
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if this Version is higher than the other Version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
    • greaterThanOrEqualTo

      @Deprecated public boolean greaterThanOrEqualTo(Version other)
      Deprecated.
      forRemoval since 0.10.0, use isHigherThanOrEquivalentTo(Version)
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if this Version is higher than or equivalent to the other Version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
    • lessThan

      @Deprecated public boolean lessThan(Version other)
      Deprecated.
      forRemoval since 0.10.0, use isLowerThan(Version)
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if this Version is lower than the other Version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
    • lessThanOrEqualTo

      @Deprecated public boolean lessThanOrEqualTo(Version other)
      Deprecated.
      forRemoval since 0.10.0, use isLowerThanOrEquivalentTo(Version)
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      true, if this Version is lower than or equivalent to the other Version; false otherwise
      Throws:
      IllegalArgumentException - if other is null
    • compareWithBuildsTo

      @Deprecated public int compareWithBuildsTo(Version other)
      Deprecated.
      forRemoval since 0.10.0, use compareTo(Version)
      Parameters:
      other - the Version to compare with, non-null
      Returns:
      a negative integer, zero or a positive integer if this Version is less than, equal to or greater than the specified Version
      Throws:
      IllegalArgumentException - if other is null