Class Version

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

public class Version extends Object implements Comparable<Version>, Serializable
Utility for parsing and comparing semantic versions.
See Also:
  • Constructor Details

    • Version

      public Version(int major)
      Creates a new instance of Version.
      Parameters:
      major - major version
    • Version

      public Version(int major, int minor)
      Creates a new instance of Version.
      Parameters:
      major - major version
      minor - minor version
    • Version

      public Version(int major, int minor, int patch)
      Creates a new instance of Version.
      Parameters:
      major - major version
      minor - minor version
      patch - patch version
    • Version

      public Version(int major, int minor, int patch, int build)
      Creates a new instance of Version.
      Parameters:
      major - major version
      minor - minor version
      patch - patch version
      build - build version
    • Version

      public Version(int... parts)
      Creates a new instance of Version.
      Parameters:
      parts - array of version parts: major, minor, patch, build
  • Method Details

    • parse

      public static Version parse(String version)
      Parses the given string representation of a version into a Version object.
      Parameters:
      version - must not be null or empty
      Returns:
      a Version
    • isGreaterThan

      public boolean isGreaterThan(Version version)
      Checks if this version is greater than the supplied version.
      Parameters:
      version - version
      Returns:
      true if greater than; otherwise false
    • isGreaterThanOrEqualTo

      public boolean isGreaterThanOrEqualTo(Version version)
      Checks if this version is greater than or equal to the supplied version.
      Parameters:
      version - version
      Returns:
      true if greater than or equal to; otherwise false
    • isLessThan

      public boolean isLessThan(Version version)
      Checks if this version is less than the supplied version.
      Parameters:
      version - version
      Returns:
      true if less than; otherwise false
    • isLessThanOrEqualTo

      public boolean isLessThanOrEqualTo(Version version)
      Checks if this version is less than or equal to the supplied version.
      Parameters:
      version - version
      Returns:
      true if less than or equal to; otherwise false
    • isSameMajorVersion

      public boolean isSameMajorVersion(Version version)
      Checks if this version has the same major version as the supplied version.
      Parameters:
      version - version
      Returns:
      true if same major version; otherwise false
    • isSameMinorVersion

      public boolean isSameMinorVersion(Version version)
      Checks if this version has the same major and minor version as the supplied version.
      Parameters:
      version - version
      Returns:
      true if same major and minor version; otherwise false
    • isSamePatchVersion

      public boolean isSamePatchVersion(Version version)
      Checks if this version has the same major, minor, and patch version as the supplied version.
      Parameters:
      version - version
      Returns:
      true if same major, minor, and patch version; otherwise false
    • nextMajor

      public Version nextMajor()
      Gets the next major version.
      Returns:
      next major Version
    • nextMinor

      public Version nextMinor()
      Gets the next minor version.
      Returns:
      next minor Version
    • nextPatch

      public Version nextPatch()
      Gets the next patch version.
      Returns:
      next patch Version
    • nextBuild

      public Version nextBuild()
      Gets the next build number version.
      Returns:
      next build number Version
    • compareTo

      public int compareTo(Version ver)
      Specified by:
      compareTo in interface Comparable<Version>
    • compareTo

      public int compareTo(String value)
    • getMajor

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

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

      public int getPatch()
      Returns the patch version.
      Returns:
      patch version
    • getBuild

      public int getBuild()
      Returns the build number.
      Returns:
      build number
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object