Class VersionNumber

    • Field Detail

      • major

        public int major
        Major version number. Example: 1 in 1.5.0_06.
      • minor

        public int minor
        Minor version number. Example: 5 in 1.5.0_06.
      • micro

        public int micro
        Micro version number. Example: 0 in 1.5.0_06.
      • levelType

        public VersionNumber.LevelType levelType
        Type of the release: alpha, beta, release candidate or patch.
      • level

        public int level
        Alpha, beta, release candidate or patch level. Example: 6 in 1.5.0_06.
      • MIN_VERSION_NUMBER

        public static final VersionNumber MIN_VERSION_NUMBER
        Minimal version number: 0.0.0-alpha00.
    • Constructor Detail

      • VersionNumber

        public VersionNumber()
        Constructs a minimal version number: 0.0.0-alpha00.
        See Also:
        MIN_VERSION_NUMBER
      • VersionNumber

        public VersionNumber​(int major,
                             int minor,
                             int micro)
        Constructs version number major.minor.micro. Example: 1.1.2.
      • VersionNumber

        public VersionNumber​(int major,
                             int minor,
                             int micro,
                             int patch)
        Constructs version number major.minor.micro_patch. Example: 3.1.0_01.
      • VersionNumber

        public VersionNumber​(int major,
                             int minor,
                             int micro,
                             VersionNumber.LevelType levelType,
                             int level)
        Constructs version number major.minor.micro (-alpha|-beta|-rc|_)level. Example: 3.1.0-beta02.
    • Method Detail

      • fromString

        public static VersionNumber fromString​(String s,
                                               boolean lenient)
        Parses specified string as a version number.
        Parameters:
        s - string to be parsed
        lenient - if true, any string starting with "\d+(\.\d+)?(\.\d+)?(_\d+)?" will be successfully parsed.
        Returns:
        parsed version number or null if it cannot be parsed.
      • parse

        public static void parse​(String s,
                                 VersionNumber version)
                          throws IllegalArgumentException
        Parses specified string and returns the result in the specified version number object.
        Parameters:
        s - string to be parsed
        version - the parsed version number is stored in this object
        Throws:
        IllegalArgumentException - if s cannot be parsed
      • hashCode

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

        public VersionNumber noLevel()
        Returns a copy of this VersionNumber but with all level info (alpha, beta, release candidate, patch) cleared.
      • toString

        public String toString()
        Returns a string having the following format: major.minor.micro if this version number is not an alpha, beta, Release candidate or patch release. Otherwise, returns a string having the following format: major.minor.micro (-alpha|-beta|-rc|_)level.
        Overrides:
        toString in class Object