Class 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 Detail

      • 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:
        Constant Field Values
      • major

        protected int major
        The major version number.
      • minor

        protected int minor
        The minor version number.
      • revision

        protected int revision
        The revision number.
    • Constructor Detail

      • 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 Detail

      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object