public class Version extends Object implements Comparable<Version>
Representation of a software version, up to major.minor.patch granularity.
Modifier and Type | Field and Description |
---|---|
static Version |
NO_VERSION |
Constructor and Description |
---|
Version(int major,
int minor,
int patch) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Version o) |
boolean |
equals(Object o) |
int |
hashCode() |
int |
major() |
int |
minor() |
static Version |
parseVersion(String versionString)
|
int |
patch() |
String |
toString() |
public static final Version NO_VERSION
public int major()
public int minor()
public int patch()
public int compareTo(Version o)
compareTo
in interface Comparable<Version>
public static final 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.
For example, the following version strings are valid: - “3.a.2”, but note it is considered only a major version since there’s a char where minor number should be (parsed into 3.0.0) - “2” (2.0.0) - “3.11” (3.11) - “1.2.3-SNAPSHOT-12.10.2014” (1.2.3)
Bad version strings cause an IllegalArgumentException
, whereas a null one will cause a NullPointerException
.
versionString
- the string to parse into a Version.IllegalArgumentException
- if the string cannot be correctly parsed into a VersionNullPointerException
- if the string is null.Copyright © 2015 Couchbase, Inc.