Class Version

java.lang.Object
com.couchbase.client.dcp.util.Version
All Implemented Interfaces:
Comparable<Version>

public class Version extends Object implements Comparable<Version>
Representation of a software version, up to major.minor.patch granularity.
  • Constructor Details

    • Version

      public Version(int major, int minor, int patch)
  • Method Details

    • major

      public int major()
    • minor

      public int minor()
    • patch

      public int patch()
    • isAtLeast

      public boolean isAtLeast(Version other)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public int compareTo(Version o)
      Specified by:
      compareTo in interface Comparable<Version>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parseVersion

      public static Version parseVersion(String versionString)
      Parses a String into a Version. This expects a version string in the form of "X[.Y[.Z]][anything]". That is a major number, followed optionally by a minor only or a minor + a patch revision, everything after that being completely ignored.

      The parsing is extremely lenient, accepting any input string whose first character is a decimal digit.

      For example, the following version strings are valid:

       - "3.a.2" (3.0.0) considered only a major version since there's a char where minor number should be
       - "2" (2.0.0)
       - "3.11" (3.11.0)
       - "3.14.15" (3.14.15)
       - "1.2.3-SNAPSHOT-12.10.2014" (1.2.3)
       

      Bad version strings cause an IllegalArgumentException, whereas a null one will cause a NullPointerException.

      Parameters:
      versionString - the string to parse into a Version.
      Returns:
      the major.minor.patch Version corresponding to the string.
      Throws:
      IllegalArgumentException - if the string cannot be correctly parsed into a Version. This happens if the input is empty, the first character is not a decimal digit, or if any version component is greater than Integer.MAX_VALUE.
      NullPointerException - if the string is null.