Class VersionNumber

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<VersionNumber>

    public final class VersionNumber
    extends java.lang.Object
    implements java.lang.Comparable<VersionNumber>, java.io.Serializable
    Represents a software version number in major.minor.revision.build format as a sequence of four shorts packed into a long. This is to facilitate meaningful comparison between version numbers.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static VersionNumber NONE
      Represents no version number or a version number which could not be parsed
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(VersionNumber other)  
      boolean equals​(java.lang.Object other)  
      short getMajor()
      Get the major version from this version number
      short getMinor()
      Get the minor version from this version number
      short getPatch()
      Get the patch from this version number
      short getRevision()
      Get the revision from this version number
      java.lang.String getSuffix()
      Get the suffix from this version
      int hashCode()  
      static VersionNumber parse​(java.lang.String version)
      Parse a version number specified as a string
      static VersionNumber parse​(java.lang.String version, java.lang.String defaultVersion)
      Parse a version number specified as a string and return default if parsing fails
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NONE

        public static final VersionNumber NONE
        Represents no version number or a version number which could not be parsed
    • Method Detail

      • getMajor

        public short getMajor()
        Get the major version from this version number
      • getMinor

        public short getMinor()
        Get the minor version from this version number
      • getPatch

        public short getPatch()
        Get the patch from this version number
      • getRevision

        public short getRevision()
        Get the revision from this version number
      • getSuffix

        public java.lang.String getSuffix()
        Get the suffix from this version
      • toString

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

        public int compareTo​(VersionNumber other)
        Specified by:
        compareTo in interface java.lang.Comparable<VersionNumber>
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • parse

        public static VersionNumber parse​(java.lang.String version)
        Parse a version number specified as a string
        Parameters:
        version - Version number to parse
        Returns:
        Version number
      • parse

        public static VersionNumber parse​(java.lang.String version,
                                          java.lang.String defaultVersion)
        Parse a version number specified as a string and return default if parsing fails
        Parameters:
        version - Version number to parse
        defaultVersion - Version number to return if parse fails
        Returns:
        Version number