Class Version

  • All Implemented Interfaces:
    Comparable<Version>

    public final class Version
    extends Object
    implements Comparable<Version>
    Represents some version in the form majorNumber.minorNumber, for instance 2.4.
    • Method Detail

      • version

        public static Version version​(int major,
                                      int minor)
        Creates a new version using the provided version information.
        Parameters:
        major - Major version number.
        minor - Minor version number.
        Returns:
        The version.
      • version

        public static Version version​(int major)
        Creates a new version using the provided version information and a minor.
        Parameters:
        major - Major version number.
        Returns:
        The version.
      • version

        public static Version version​(String s)
        Parses the string argument as a version. The string must be one of the following forms:
         major
         major.minor
         
        Parameters:
        s - The non-null string to be parsed as a version.
        Returns:
        The parsed version.
        Throws:
        IllegalArgumentException - If the string does not contain a parsable version.
      • getMajor

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

        public int getMinor()
        Returns the minor version number.
        Returns:
        The minor version number.
      • hashCode

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

        public boolean isCompatibleWith​(Version that)
        Returns false if:
        • the MAJOR version numbers are not the same.
        • the MAJOR version numbers are the same but this MINOR version number is LOWER than that MINOR version number.

        i.e. this version number - "2.0", that version number - "2.1" WILL NOT match, but this version number - "2.4", that version number - "2.1" WILL match. In other words, verifies ascending compatibility.

        Parameters:
        that - The Version to match against.
        Returns:
        true if both MAJOR version numbers are the same and if this MINOR version number is HIGHER than that MINOR version number.