Class SemanticVersion


  • public final class SemanticVersion
    extends Object
    A semantic version representation.
    • Field Detail

      • VERSION_SUFFIX_SNAPSHOT

        public static final String VERSION_SUFFIX_SNAPSHOT
        Version suffix for the development version in case of Maven repo layouts.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SemanticVersion

        public SemanticVersion​(int major,
                               int minor,
                               int patch)
        Constructor to construct a semantic version.
        Parameters:
        major - The major version part.
        minor - The minor version part.
        patch - The patch version part.
    • Method Detail

      • equals

        public boolean equals​(Object o)
        Check another object for equality with this.
        Overrides:
        equals in class Object
        Parameters:
        o - The other object.
        Returns:
        true if the other object is a semantic version and the version parts are equal, false otherwise.
      • hashCode

        public int hashCode()
        Hashcode for the class.
        Overrides:
        hashCode in class Object
        Returns:
        The hash code.
      • getMajor

        public int getMajor()
        Returns the major version part of this semantic version.
        Returns:
        The major version part.
      • getMinor

        public int getMinor()
        Returns the minor part of this semantic version.
        Returns:
        The minor version part.
      • getPatch

        public int getPatch()
        Returns the patch version part of this semantic version.
        Returns:
        The patch version part.
      • releaseVersion

        public SemanticVersion releaseVersion​(SemanticVersionChange change)
        Calculates and returns the next semantic version based on the given change.
        Parameters:
        change - The change (major, minor...).
        Returns:
        The adjusted semantic version.
      • nextDevelopmentVersion

        public SemanticVersion nextDevelopmentVersion​(SemanticVersionChange change)
        Calculates and returns the development version to be setup after the next release by the maven release plugin, based on the given change type.
        Parameters:
        change - The version change (major, minor, ...)
        Returns:
        The calculated version change.
      • toString

        public String toString()
        toString for this version.
        Overrides:
        toString in class Object
        Returns:
        The semantic version as string.
      • parse

        public static SemanticVersion parse​(String version)
        Factory method to parse a string formatted semantic version and construct a semantic version object.
        Parameters:
        version - The version string.
        Returns:
        The semantic version object, or IllegalArgumentException is thrown.
      • getDevelopmentVersionString

        public String getDevelopmentVersionString()
        Returns the development version as a maven snapshot version, after releasing the current changes.
        Returns:
        The version string to be used as the next snapshot version in case of maven repo layouts.