Class Version

java.lang.Object
qupath.lib.common.Version
All Implemented Interfaces:
Comparable<Version>

public class Version extends Object implements Comparable<Version>
Helper class for working with semantic versioning.

This should be in the form major.minor.patch. An optional suffix is also permitted to indicate a pre-release, alpha, beta or milestone version, in the form major.minor.patch-suffix, where the suffix may contain any alphanumeric characters or periods.

Implementation note: No checking is currently performed to ensure any suffix conforms to semantic versioning standards - however this behavior may change.

Author:
Pete Bankhead
  • Field Details

    • COMPARATOR_MAJOR

      public static final Comparator<Version> COMPARATOR_MAJOR
      Compare major versions only.
    • COMPARATOR_MAJOR_MINOR

      public static final Comparator<Version> COMPARATOR_MAJOR_MINOR
      Compare major then minor versions.
    • COMPARATOR_MAJOR_MINOR_PATCH

      public static final Comparator<Version> COMPARATOR_MAJOR_MINOR_PATCH
      Compare major then minor then patch versions (ignoring suffixes).
    • COMPARATOR_FULL

      public static final Comparator<Version> COMPARATOR_FULL
      Compare full version, including any suffixes.
    • UNKNOWN

      public static final Version UNKNOWN
      Constant representing any unknown version.
  • Method Details

    • getMajor

      public int getMajor()
      Get the major version number (X.0.0).
      Returns:
    • getMinor

      public int getMinor()
      Get the minor version number (0.X.0).
      Returns:
    • getPatch

      public int getPatch()
      Get the patch version number (0.0.X).
      Returns:
    • getSuffix

      public String getSuffix()
      Get the (optional) suffix, which may be appended at the end of the version number to indicate a pre-release (0.0.0-X).
      Returns:
    • hasSuffix

      public boolean hasSuffix()
      Returns true if the version has a suffix, which typically indicates that it does not refer to a final stable version.
      Returns:
    • toString

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

      public static Version parse(String versionString) throws IllegalArgumentException
      Parse a Version object representing a semantic version number from a String.

      The version should be in the form x.y.z or x.y.z-additional, where additional should be a dot-separated patch version identifier. In the case that it is hyphen-separated, the hyphens will be replaced by dots.

      Parameters:
      versionString - the version String to be parsed
      Returns:
      a Version parsed from this string, or UNKNOWN if the string is null or blank.
      Throws:
      IllegalArgumentException - if no version could be parsed from the String
    • compareTo

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

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object