Class Version

  • All Implemented Interfaces:
    java.lang.Comparable<Version>

    public final class Version
    extends java.lang.Object
    implements java.lang.Comparable<Version>
    Encapsulates a version number. A version number is composed of up to four components: major, minor, micro and specification number.
    Since:
    1.1
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Version that)  
      static Version create​(java.lang.Integer... components)
      Creates a new version from components.
      boolean equals​(java.lang.Object o)  
      java.lang.Integer getMajor()
      Returns this version number's major component.
      java.lang.Integer getMicro()
      Returns this version number's minor component.
      java.lang.Integer getMinor()
      Returns this version number's minor component.
      java.lang.Integer getRevision()
      Returns this version number's minor component.
      java.lang.String getVersion()
      Returns this version as a string.
      int hashCode()  
      static Version parse​(java.lang.String version)
      Parses the passed version string.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • parse

        public static Version parse​(java.lang.String version)
        Parses the passed version string. The string can contain up to four numeric component separated by a dot, followed by an alphanumberic qualifier prepended by a dash. For example, the following are valid versions:
        • 1
        • 1.1
        • 1.1.0
        • 1.2.3-alpha
        • 1.2.3.4-SNAPSHOT
        Parameters:
        version - the version string.
      • create

        public static Version create​(java.lang.Integer... components)
        Creates a new version from components.
        Parameters:
        components - the components
      • getMajor

        public java.lang.Integer getMajor()
        Returns this version number's major component.
        Returns:
        the major component; never null.
      • getMinor

        public java.lang.Integer getMinor()
        Returns this version number's minor component.
        Returns:
        the minor component or null if this version number doesn't have a minor component.
      • getMicro

        public java.lang.Integer getMicro()
        Returns this version number's minor component.
        Returns:
        the minor component or null if this version number doesn't have a minor component.
      • getRevision

        public java.lang.Integer getRevision()
        Returns this version number's minor component.
        Returns:
        the minor component or null if this version number doesn't have a revision component.
      • getVersion

        public java.lang.String getVersion()
        Returns this version as a string.
        Returns:
        this version as a string.
      • hashCode

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(Version that)
        Specified by:
        compareTo in interface java.lang.Comparable<Version>
      • toString

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