Class SemanticVersion

    • Field Detail

      • DEFAULT_INITIAL_VERSION

        public static final String DEFAULT_INITIAL_VERSION
        The default initial version that can be used when non version is yet available.
        See Also:
        Constant Field Values
      • PRERELEASE_DELIMITER

        public static final char PRERELEASE_DELIMITER
        The character that marks the separation between the core and the pre-release part. Note that this character is used as separator only at the first occurrence while other occurrences are considered legal characters in the pre-release and the build identifiers.
        See Also:
        Constant Field Values
      • BUILD_DELIMITER

        public static final char BUILD_DELIMITER
        The character that marks the separation between the core or the pre-release part and the build part.
        See Also:
        Constant Field Values
      • SEMANTIC_VERSION_PATTERN_RELAXED

        public static final String SEMANTIC_VERSION_PATTERN_RELAXED
        A relaxed version of the SEMANTIC_VERSION_PATTERN that works also when a prefix appears at the beginning of the version string or some zeroes appear in front of numbers. Value is: "([0-9]\\d*)\\.([0-9]\\d*)\\.([0-9]\\d*)(?:-((?:[0-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:[0-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
        See Also:
        SEMANTIC_VERSION_PATTERN, Constant Field Values
      • SEMANTIC_VERSION_PATTERN

        public static final String SEMANTIC_VERSION_PATTERN
        The regexp pattern taken directly from Semantic Versioning 2.0.0 used to parse semantic versions. Value is: "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
        See Also:
        Constant Field Values
    • Constructor Detail

      • SemanticVersion

        public SemanticVersion​(int major,
                               int minor,
                               int patch)
        Builds a new version object with the given values.
        Parameters:
        major - the major number
        minor - the minor number
        patch - the patch number
        Throws:
        IllegalArgumentException - if one of major, minor, patch is negative
      • SemanticVersion

        public SemanticVersion​(int major,
                               int minor,
                               int patch,
                               Object[] prereleaseIdentifiers,
                               String[] buildIdentifiers)
        Builds a new version object with the given values.
        Parameters:
        major - the major number
        minor - the minor number
        patch - the patch number
        prereleaseIdentifiers - the prereleaseIdentifiers the array of Integer or String objects to use as identifiers in the prerelease block. null items are ignored. Integers and strings representing integers must not have leading zeroes or represent negative numbers. If the array is null then the instance will have no prerelease block
        buildIdentifiers - the buildIdentifiers the array of String to use as identifiers in the build block. null items are ignored. If the array is null then the instance will have no build block
        Throws:
        IllegalArgumentException - if one of major, minor, patch is negative or one object in the prereleaseIdentifiers represents a negative integer (either when passed as an Integer or String) or have leading zeroes. This exception is also raised when objects in the prereleaseIdentifiers are not of type Integer or String or when string identifiers in the prereleaseIdentifiers or buildIdentifiers contain illegal characters
    • Method Detail

      • hashCode

        public int hashCode()
        Returns a hash code value for the object.
        Specified by:
        hashCode in class Version
        Returns:
        a hash code value for this object.
      • equals

        public boolean equals​(Object obj)
        Indicates whether some other object is "equal to" this one. This object equals to the given one if they are the same object or they are of the same type and hold exactly the same version.
        Specified by:
        equals in class Version
        Parameters:
        obj - the reference object with which to compare.
        Returns:
        true if this object is the same as the obj argument; false otherwise.
        See Also:
        Object.equals(Object)
      • compareTo

        public int compareTo​(SemanticVersion v)
        Compares this version with the specified version for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified version.

        Semantic Versioning 2.0.0 states that:
        - rule #9: Pre-release versions have a lower precedence than the associated normal version.
        - rule #10: Build metadata MUST be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence.
        - rule #11: Precedence refers to how versions are compared to each other when ordered. Precedence MUST be calculated by separating the version into major, minor, patch and pre-release identifiers in that order (Build metadata does not figure into precedence). Precedence is determined by the first difference when comparing each of these identifiers from left to right as follows: Major, minor, and patch versions are always compared numerically. Example: 1.0.0 < 2.0.0 < 2.1.0 < 2.1.1.
        When major, minor, and patch are equal, a pre-release version has lower precedence than a normal version. Example: 1.0.0-alpha < 1.0.0.
        Precedence for two pre-release versions with the same major, minor, and patch version MUST be determined by comparing each dot separated identifier from left to right until a difference is found as follows:
        - identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order.
        - numeric identifiers always have lower precedence than non-numeric identifiers
        - a larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.

        Note that when the specification says "lower precedence" it translates to <, which means the "less" part is supposed to appear first in order. Translating this to the Comparable.compareTo(Object) method, it means that the object with "lower precedence" returns a negative number.

        However, to cope with the Comparable contract, which imposes a total ordering, we need to amend the above rules and make them s little stricter just because two versions with different values can't be considered equal (also see equals(Object)). With more detail:
        - rule #10 is amended so that two versions that only differ in their build metadata will not return 0 (as if they the same) but their build metadata of two versions that are equal in their core and prerelease parts affects the order by their literal comparison (remember that numeric identifiers are not treated as such in build metadata and, instead, they are just treated as strings). In other words we are not ignoring build metadata as required by rule #10 but we consider it with the least priority only when the core and prerelease parts are the same. Two be consistent with rule #9, when comparing two versions with the same core and prerelease parts, when one has build metadata and the other doesn't, the one with the build metadata has lower precedence on the one without the build metadata. Example: 1.2.3+build.1 < 1.2.3 and 1.2.3-alpha.0+build.1 < 1.2.3-alpha.0.
        Specified by:
        compareTo in interface Comparable<SemanticVersion>
        Parameters:
        v - the version to be compared.
        Returns:
        a negative integer, zero, or a positive integer as this version is less than, equal to, or greater than the specified version.
        See Also:
        Comparable.compareTo(Object)
      • isLegal

        public static boolean isLegal​(String s)
        Returns true if the given string is a legal semantic version which, for example, can be parsed using valueOf(String) without exceptions.
        This method uses a strict criteria, without trying to sanitize the given string.
        Parameters:
        s - the string version to check.
        Returns:
        true if the given string represents a legal semantic version, false otherwise.
        See Also:
        valueOf(String)
      • isLegal

        public static boolean isLegal​(String s,
                                      boolean lenient)
        Returns true if the given string is a legal semantic version which, for example, can be parsed using valueOf(String, boolean) without exceptions.
        Parameters:
        s - the string version to check.
        lenient - when true prefixes and non critical extra characters are tolerated even if they are not strictly legal from the semantic version specification perspective.
        Returns:
        true if the given string represents a legal semantic version, false otherwise.
        See Also:
        valueOf(String, boolean)
      • toString

        public String toString()
        Returns a string representation of the object.
        Specified by:
        toString in class Version
        Returns:
        a string representation of the object.
        See Also:
        Object.toString()
      • valueOf

        public static SemanticVersion valueOf​(String s,
                                              boolean sanitize)
        This method is a shorthand for valueOf(String) and sanitize(String).
        Returns a SemanticVersion instance representing the specified String value. If sanitize is true this method will try to sanitize the given string before parsing so that if there are illegal characters like a prefix or leading zeroes in numeric identifiers they are removed.
        When sanitization is enabled on a string that actually needs sanitization the string representation of the returned object will not exactly match the input value.
        Parameters:
        s - the string to parse
        sanitize - optionally enables sanitization before parsing
        Returns:
        the new SemanticVersion instance representing the given string.
        Throws:
        NullPointerException - if the given string is null
        IllegalArgumentException - if the given string doesn't represent a legal semantic version
        See Also:
        valueOf(String), sanitizePrefix(String)
      • sanitize

        public static String sanitize​(String s)
        Performs all of the sanitizations in the given string by sanitizing, in order, the prefix and leading zeroes in numeric identifiers. This order is the one that yields to the highest success probability in obtaining a legal version. Invoking this method is like invoking the sanitization methods sanitizeNumbers(String) and sanitizePrefix(String).
        Parameters:
        s - the semantic version string to sanitize
        Returns:
        the sanitized semantic string version
        Throws:
        NullPointerException - if the given string is null
        IllegalArgumentException - if the given string doesn't represent a semantic version, even tolerating the aspects to sanitize
        See Also:
        sanitizePrefix(String), sanitizeNumbers(String)
      • sanitizeNumbers

        public static String sanitizeNumbers​(String s)
        Takes the given string and tries to parse it as a semantic version number, even with illegal characters or prefix. All numeric identifiers in the core version (major.minor.patch) and in the prerelease metadata are sanitized by removing all leading zeroes to make them compliant. Numeric identifiers in the build metadata part are left intact, even when they have leading zeroes. If the given string contains a prefix (see sanitizePrefix(String)) or illegal characters they are left untouched and they are returned as they were in the input string.
        Parameters:
        s - a semantic version string which may have illegal leading zeroes to be removed in the numeric identifiers in the core or the prerelease parts.
        Returns:
        the string given as input with the illegal leading zeroes removed.
        Throws:
        NullPointerException - if the given string is null
        IllegalArgumentException - if the given string doesn't represent a legal semantic version, even tolerating the prefix
        See Also:
        sanitize(String)
      • sanitizePrefix

        public static String sanitizePrefix​(String s)
        Takes the given string and tries to parse it as a semantic version with an optional prefix (which may be any string before the core major.minor.patch numbers). The returned string is the semantic version passed as input with the prefix removed. If no prefix is present then the returned string is the same as the one passed as input. Prefixes are often used (i.e. the 'v' used it Git tags or release-, rel etc) so this method helps in stripping those prefixes to get a compliant semantic version.
        Parameters:
        s - a semantic version string which may have an additional prefix to be removed
        Returns:
        the string given as input with the prefix removed, if any, or the same string passed as input if no prefix was found.
        Throws:
        NullPointerException - if the given string is null
        IllegalArgumentException - if the given string doesn't represent a legal semantic version, even tolerating the prefix
        See Also:
        sanitize(String), getPrefix(String)
      • getPrefix

        public static String getPrefix​(String s)
        Takes the given string and tries to parse it as a semantic version with an optional prefix (which may be any string before the core major.minor.patch numbers). The returned string is the prefix before the core version number, if any, or null otherwise.
        Parameters:
        s - a semantic version string which may have an additional prefix to be isolated
        Returns:
        the prefix in the given semantic version string, if any, or null otherwise. null is also returned when the given string is empty.
        Throws:
        NullPointerException - if the given string is null
        IllegalArgumentException - if the given string is not empty but doesn't represent a legal semantic version, even tolerating the prefix
        See Also:
        sanitizePrefix(String)
      • getMajor

        public int getMajor()
        Returns the major version number
        Returns:
        the major version number
      • getMinor

        public int getMinor()
        Returns the minor version number
        Returns:
        the minor version number
      • getPatch

        public int getPatch()
        Returns the patch version number
        Returns:
        the patch version number
      • getCore

        public String getCore()
        Returns the core part (major.minor.patch) of the version as a string.
        Returns:
        the core part of the version as a string.
      • getCoreIdentifiers

        public Integer[] getCoreIdentifiers()
        Returns an array of the single identifiers of the core part of the version
        Returns:
        the identifiers of the core part of the version.
      • getPrerelease

        public String getPrerelease()
        Returns the prerelease part of the version, if any, or null otherwise.
        Returns:
        the prerelease part of the version.
      • getPrereleaseIdentifiers

        public Object[] getPrereleaseIdentifiers()
        Returns an array of the single identifiers of the prerelease part of the version, if any, or null otherwise.
        Returns:
        the identifiers of the prerelease part of the version. The objects in the array can be either Integer or String.
      • getBuild

        public String getBuild()
        Returns the build part of the version, if any, or null otherwise.
        Returns:
        the build part of the version.
      • getBuildIdentifiers

        public String[] getBuildIdentifiers()
        Returns an array of the single identifiers of the build part of the version, if any, or null otherwise.
        Returns:
        the identifiers of the build part of the version.
      • setCore

        public SemanticVersion setCore​(int major,
                                       int minor,
                                       int patch)
        Returns a new version object with the major, minor and patch numbers set to the given values. This method doesn't reset any number and the prerelease and build blocks are left unchanged.
        Parameters:
        major - the major number to set
        minor - the minor number to set
        patch - the patch number to set
        Returns:
        the new version instance
        Throws:
        IllegalArgumentException - if any of the given values is negative
      • setMajor

        public SemanticVersion setMajor​(int major)
        Returns a new version object with the major number set to the given value. This method doesn't reset any number and the prerelease and build blocks are left unchanged.
        Parameters:
        major - the major number to set
        Returns:
        the new version instance
        Throws:
        IllegalArgumentException - if the given values is negative
      • setMinor

        public SemanticVersion setMinor​(int minor)
        Returns a new version object with the minor number set to the given value. This method doesn't reset any number and the prerelease and build blocks are left unchanged.
        Parameters:
        minor - the minor number to set
        Returns:
        the new version instance
        Throws:
        IllegalArgumentException - if the given values is negative
      • setPatch

        public SemanticVersion setPatch​(int patch)
        Returns a new version object with the patch number set to the given value. This method doesn't reset any number and the prerelease and build blocks are left unchanged.
        Parameters:
        patch - the patch number to set
        Returns:
        the new version instance
        Throws:
        IllegalArgumentException - if the given values is negative
      • setPrerelease

        public SemanticVersion setPrerelease​(Object... identifiers)
        Returns a new version object with the prerelease part set to the given values. If a null value or an array of all null values is passed then the returned version will have no prerelease part, otherwise it will have all of the given non null identifiers, with the core and build elements of this version instance.
        Parameters:
        identifiers - the identifiers to use for the new version instance, or null to remove the prerelease block. All non null items must be String or Integer instances. String instances representing numeric values will be interpreted as Integer. If the current version had a pre-release part it is completely replaced by the given identifiers.
        Returns:
        the new version instance
        Throws:
        IllegalArgumentException - if some non null item passed contains illegal characters, if a given number is negative or contains leading zeroes or any item is not an instance of String or Integer
      • setBuild

        public SemanticVersion setBuild​(String... identifiers)
        Returns a new version object with the build part set to the given values. If a null value or an array of all null values is passed then the returned version will have no build part, otherwise it will have all of the given non null identifiers, with the core and prerelease elements of this version instance. If the current version had a build part it is completely replaced by the given identifiers.
        Parameters:
        identifiers - the identifiers to use for the new version instance, or null to remove the build block
        Returns:
        the new version instance
        Throws:
        IllegalArgumentException - if some non null item passed contains illegal characters
      • hasPrereleaseAttribute

        public boolean hasPrereleaseAttribute​(String name)
        Returns true if an attribute with the given name is present in the prerelease part, false otherwise.
        Parameters:
        name - the name of the attribute to look up. If null or empty false is returned
        Returns:
        true if an attribute with the given name is present in the prerelease part, false otherwise.
      • hasBuildAttribute

        public boolean hasBuildAttribute​(String name)
        Returns true if an attribute with the given name is present in the build part, false otherwise.
        Parameters:
        name - the name of the attribute to look up. If null or empty false is returned
        Returns:
        true if an attribute with the given name is present in the build part, false otherwise.
      • getPrereleaseAttributeValue

        public Integer getPrereleaseAttributeValue​(String name)
        If an attribute with the given name is present in the prerelease part, return the identifier after that, otherwise return null.
        Parameters:
        name - the name of the attribute to look up. If null or empty null is returned
        Returns:
        the attribute after the given name if such attribute is found in the prerelease part and there is another attribute after it, otherwise null
      • getBuildAttributeValue

        public String getBuildAttributeValue​(String name)
        If an attribute with the given name is present in the build part, return the identifier after that, otherwise return null.
        Parameters:
        name - the name of the attribute to look up. If null or empty null is returned
        Returns:
        the attribute after the given name if such attribute is found in the build part and there is another attribute after it, otherwise null
      • setPrereleaseAttribute

        public SemanticVersion setPrereleaseAttribute​(String name,
                                                      Integer value)
        Returns a new version object with the new attribute added or replaced in the prerelease part. This method tries to be less intrusive as it only works on the given attribute (and its optional value) while leaving the other attributes unchanged.
        If this version doesn't have a prerelease part, the returned version will have one with the new attribute appended (and its value as well, if not null).
        If this version already has a prerelease part with no identifier matching the given attribute name then the returned version will have the same prerelease part as the current one with the new attribute appended (and its value as well, if not null).
        If this version already has a prerelease part that contains an identifier matching the given attribute name then the identifier matching the attribute name is left unchanged and if the given value is not null, the next identifier is added or replaced with the given value.
        ATTENTION: if the value is not null the current identifier after the name (if any) is replaced if it's a numeric identifier.
        Examples of invoking setPrereleaseAttribute("build") with null value:
        - 1.2.3 = 1.2.3-build
        - 1.2.3-alpha = 1.2.3-alpha.build
        - 1.2.3-alpha.beta = 1.2.3-alpha.beta.build
        - 1.2.3+timestamp = 1.2.3-build+timestamp
        - 1.2.3-alpha+timestamp.20200101 = 1.2.3-alpha.build+timestamp.20200101
        - 1.2.3-build = 1.2.3-build (unchanged)
        - 1.2.3-build.12345 = 1.2.3-build.12345 (unchanged)
        - 1.2.3-build.12345.timestamp.20200101 = 1.2.3-build.12345.timestamp.20200101 (unchanged)

        Examples of invoking setPrereleaseAttribute("build") with 12345 value:
        - 1.2.3 = 1.2.3-build.12345
        - 1.2.3-alpha = 1.2.3-alpha.build.12345
        - 1.2.3-alpha.beta = 1.2.3-alpha.beta.build.12345
        - 1.2.3+timestamp = 1.2.3-build.12345+timestamp
        - 1.2.3-alpha+timestamp.20200101 = 1.2.3-alpha.build.12345+timestamp.20200101
        - 1.2.3-build = 1.2.3-build.12345
        - 1.2.3-build.12345 = 1.2.3-build.12345 (unchanged)
        - 1.2.3-build.12345.timestamp.20200101 = 1.2.3-build.12345.timestamp.20200101 (unchanged)
        Parameters:
        name - the name to set for the attribute
        value - the value to set for the attribute, or null just set the attribute name, ignoring the value
        Returns:
        the new version instance
        Throws:
        IllegalArgumentException - if the given name or value contains illegal characters
        NullPointerException - if the attribute name is null
      • setBuildAttribute

        public SemanticVersion setBuildAttribute​(String name,
                                                 String value)
        Returns a new version object with the new attribute added or replaced in the build part. This method tries to be less intrusive as it only works on the given attribute (and its optional value) while leaving the other attributes unchanged.
        If this version doesn't have a build part, the returned version will have one with the new attribute appended (and its value as well, if not null).
        If this version already has a build part with no identifier matching the given attribute name then the returned version will have the same build part as the current one with the new attribute appended (and its value as well, if not null).
        If this version already has a build part that contains an identifier matching the given attribute name then the identifier matching the attribute name is left unchanged and if the given value is not null, the next identifier is added or replaced with the given value.
        ATTENTION: if the value is not null the current identifier after the name (if any) is replaced without further consideration.
        Examples of invoking setBuildAttribute("build") with null value:
        - 1.2.3 = 1.2.3+build
        - 1.2.3-alpha = 1.2.3-alpha+build
        - 1.2.3-alpha.beta = 1.2.3-alpha.beta+build
        - 1.2.3+timestamp = 1.2.3+timestamp.build
        - 1.2.3-alpha+timestamp.20200101 = 1.2.3-alpha+timestamp.20200101.build
        - 1.2.3+build = 1.2.3+build (unchanged)
        - 1.2.3+build.12345 = 1.2.3+build.12345 (unchanged)
        - 1.2.3+build.12345.timestamp.20200101 = 1.2.3+build.12345.timestamp.20200101 (unchanged)

        Examples of invoking setBuildAttribute("build") with 12345 value:
        - 1.2.3 = 1.2.3+build.12345
        - 1.2.3-alpha = 1.2.3-alpha+build.12345
        - 1.2.3-alpha.beta = 1.2.3-alpha.beta+build.12345
        - 1.2.3+timestamp = 1.2.3+timestamp.build.12345
        - 1.2.3-alpha+timestamp.20200101 = 1.2.3-alpha+timestamp.20200101.build.12345
        - 1.2.3+build = 1.2.3+build.12345
        - 1.2.3+build.12345 = 1.2.3+build.12345 (unchanged)
        - 1.2.3+build.12345.timestamp.20200101 = 1.2.3+build.12345.timestamp.20200101 (unchanged)
        Parameters:
        name - the name to set for the attribute
        value - the value to set for the attribute, or null just set the attribute name, ignoring the value
        Returns:
        the new version instance
        Throws:
        IllegalArgumentException - if the given name or value contains illegal characters
        NullPointerException - if the attribute name is null
      • removePrereleaseAttribute

        public SemanticVersion removePrereleaseAttribute​(String name,
                                                         boolean removeValue)
        Returns a new instance with the new attribute removed from the prerelease part, if any was present, otherwise the same version is returned. If the attribute is found and removeValue is true then also the attribute value (the attribute after the one identified by name) is removed, unless there are no more attributes after name or the value attribute is not numeric.
        Parameters:
        name - the name of the attribute to remove from the prerelease part, if present. If null or empty no action is taken
        removeValue - if true also the attribute after name is removed (if any)
        Returns:
        the new instance, which might be the same of the current object if no attribute with the given name is present
      • removeBuildAttribute

        public SemanticVersion removeBuildAttribute​(String name,
                                                    boolean removeValue)
        Returns a new instance with the new attribute removed from the build part, if any was present, otherwise the same version is returned. If the attribute is found and removeValue is true then also the attribute value (the attribute after the one identified by name) is removed, unless there are no more attributes after name.
        Parameters:
        name - the name of the attribute to remove from the build part, if present. If null or empty no action is taken
        removeValue - if true also the attribute after name is removed (if any)
        Returns:
        the new instance, which might be the same of the current object if no attribute with the given name is present
      • bumpMajor

        public SemanticVersion bumpMajor()
        Returns a new instance with the major number of this current instance incremented by one and the minor and patch numbers reset to zero. Prerelease and build parts are left intact.
        Returns:
        a new instance with the major number of this current instance incremented by one and the minor and patch numbers reset to zero.
      • bumpMinor

        public SemanticVersion bumpMinor()
        Returns a new instance with the major number of this current instance, the minor number incremented by one and the patch number reset to zero. Prerelease and build parts are left intact.
        Returns:
        a new instance with the major number of this current instance, the minor number incremented by one and the patch number reset to zero.
      • bumpPatch

        public SemanticVersion bumpPatch()
        Returns a new instance with the major and minor numbers of this current instance and the patch number incremented by one. Prerelease and build parts are left intact.
        Returns:
        a new instance with the major and minor numbers of this current instance and the patch number * incremented by one.
      • bump

        public SemanticVersion bump​(CoreIdentifiers id)
        Returns a new instance with the number identified by the given value bumped.
        Parameters:
        id - the selector of the identifier to bump
        Returns:
        a new instance with the number identified by the given value bumped.
        Throws:
        NullPointerException - if null is passed
      • bumpPrerelease

        public SemanticVersion bumpPrerelease​(String id)
        Returns a new instance with the number identified by the given value bumped in the prerelease part. The core and the build blocks (if present) are left unchanged.
        If this version doesn't have a prerelease block the returned version will have one, containing two identifiers: the given string and the following number .0.
        If this version already has a prerelease block without any identifier that equals the given id, then the returned version has all the previous prerelease identifiers preceded by the two new identifiers the given string and the following number .1. If this version already has a prerelease block that contains a string identifier equal to the given id there are two options: if the selected identifier already has a numeric value that follows, the returned version will have that numeric identifier incremented by one; if the selected identifier doesn't have a numeric identifier that follows, a new numeric identifiers is added after the string with the initial value .1.
        If the version already has multiple identifiers in the prerelease block that equal to the given value then all of them will be bumped. In case they have different numeric values (or missing) each occurrence is bumped independently according to the above rules.
        Examples of invoking bumpPrerelease("alpha") on different versions:
        - 1.2.3 = 1.2.3-alpha.0
        - 1.2.3-alpha = 1.2.3-alpha.0
        - 1.2.3-alpha.beta = 1.2.3-alpha.0.beta
        - 1.2.3-gamma = 1.2.3-alpha.0.gamma
        - 1.2.3-gamma.delta = 1.2.3-alpha.0.gamma.delta
        - 1.2.3+999 = 1.2.3-alpha.0+999
        - 1.2.3-alpha+999 = 1.2.3-alpha.0+999
        - 1.2.3-alpha.beta+999 = 1.2.3-alpha.0.beta+999
        - 1.2.3-gamma+999 = 1.2.3-alpha.0.gamma+999
        - 1.2.3-gamma.delta+999 = 1.2.3-alpha.0.gamma.delta+999
        - 1.2.3-alpha.alpha.1.alpha.2 = 1.2.3-alpha.0.alpha.2.alpha.3
        Parameters:
        id - the selector of the identifier to bump
        Returns:
        a new instance with the number identified by the given value bumped.
        Throws:
        NullPointerException - if null is passed
        IllegalArgumentException - if the given string is empty, contains illegal characters or represents a number
      • bump

        public SemanticVersion bump​(String id)
        Returns a new instance with the number identified by the given value bumped. If the given value represents a core identifier (CoreIdentifiers, namely major, minor, patch) then that identifier is bumped, otherwise the given id is used to bump a prerelease identifier by invoking bumpPrerelease(String).
        In other words this method is a shorthand for bump(CoreIdentifiers) and bumpPrerelease(String), the latter being used only when the given id is not a core identifier.
        If the version already has multiple identifiers in the prerelease block that equal to the given value then all of them will be bumped. In case they have different numeric values (or missing) each occurrence is bumped independently according to the above rules.
        Specified by:
        bump in class Version
        Parameters:
        id - the name of the identifier to bump
        Returns:
        a new instance with the number identified by the given value bumped.
        Throws:
        NullPointerException - if null is passed
        IllegalArgumentException - if the given string is empty, contains illegal characters or represents a number
        See Also:
        CoreIdentifiers, bump(CoreIdentifiers), bumpPrerelease(String)