Class Version

java.lang.Object
org.gcube.informationsystem.utils.Version
All Implemented Interfaces:
Comparable<Version>

public final class Version extends Object implements Comparable<Version>
A class representing and validating a version in the following format X.X.X (Major.Minor.Revision) Each part is an integer with no trailing zeros (e.g 1 and not 01). The version is validated by the regex defined in the static field VERSION_REGEX Accepted initial version is MINIMAL_VERSION_STRING
Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • VERSION_REGEX

      public static final String VERSION_REGEX
      Regex validating the version
      See Also:
    • MINIMAL_VERSION_STRING

      public static final String MINIMAL_VERSION_STRING
      Accepted initial version
      See Also:
    • MINIMAL_VERSION

      public static final Version MINIMAL_VERSION
      Accepted initial version as TypeVersion instance
    • MINIMAL_VERSION_DESCRIPTION

      public static final String MINIMAL_VERSION_DESCRIPTION
      Default changelog description for the initial version
      See Also:
    • major

      protected int major
      The major version number.
    • minor

      protected int minor
      The minor version number.
    • revision

      protected int revision
      The revision number.
  • Constructor Details

    • Version

      protected Version()
      Default constructor.
    • Version

      public Version(String version)
      Constructs a new Version from a string.
      Parameters:
      version - the version string
    • Version

      public Version(int major, int minor, int revision)
      Constructs a new Version from its major, minor, and revision numbers.
      Parameters:
      major - the major version number
      minor - the minor version number
      revision - the revision number
  • Method Details

    • setVersion

      public void setVersion(String version)
      Sets the version from a string.
      Parameters:
      version - the version string
    • check

      protected void check()
      Checks if the version is valid.
    • getMajor

      public int getMajor()
      Gets the major version number.
      Returns:
      the major version number
    • setMajor

      protected void setMajor(int major)
      Sets the major version number.
      Parameters:
      major - the major version number
    • getMinor

      public int getMinor()
      Gets the minor version number.
      Returns:
      the minor version number
    • setMinor

      protected void setMinor(int minor)
      Sets the minor version number.
      Parameters:
      minor - the minor version number
    • getRevision

      public int getRevision()
      Gets the revision number.
      Returns:
      the revision number
    • setRevision

      protected void setRevision(int revision)
      Sets the revision number.
      Parameters:
      revision - the revision number
    • toString

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

      public int compareTo(Version other)
      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