public class VersionNumber extends Object implements Comparable<VersionNumber>
Version numbers compare the usual way, the major number (X) is compared first, then the minor one (Y) and then the patch level one (Z). Lastly, versions with pre-release sorts before the versions that don't have one, and labels are sorted alphabetically if necessary. Build metadata are ignored for sorting versions. The versions supported loosely correspond to what http://semver.org/ defines though it does not adhere to it strictly.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(VersionNumber other) |
boolean |
equals(Object other) |
String |
getBuildLabel()
The build label if there is one.
|
int |
getDSEPatch()
The DSE patch version number (will only be present for version of Cassandra in DSE).
|
int |
getMajor()
The major version number.
|
int |
getMinor()
The minor version number.
|
int |
getPatch()
The patch version number.
|
List<String> |
getPreReleaseLabels()
The pre-release labels if relevant, i.e.
|
int |
hashCode() |
VersionNumber |
nextStable()
The next stable version, i.e.
|
static VersionNumber |
parse(String version)
Parse a version from a string.
|
String |
toString() |
public static VersionNumber parse(String version)
The version string should have primarily the form X.Y.Z to which can be appended one or more pre-release label after dashes (2.0.1-beta1, 2.1.4-rc1-SNAPSHOT) and an optional build label (2.1.0-beta1+a20ba.sha). Out of convenience, the "patch" version number, Z, can be omitted, in which case it is assumed to be 0.
version
- the string to parseIllegalArgumentException
- if the provided string does not represent a valid version.public int getMajor()
public int getMinor()
public int getPatch()
public int getDSEPatch()
DataStax Entreprise (DSE) adds a fourth number to the version number to track potential hot fixes and/or DSE specific patches that may have been applied to the Cassandra version. In that case, this method return that fourth number.
public List<String> getPreReleaseLabels()
null
if the version number
doesn't have one.public String getBuildLabel()
null
if the version number doesn't have one.public VersionNumber nextStable()
This is mostly used during our development stage, where we test the driver against pre-release versions of Cassandra like 2.1.0-rc7-SNAPSHOT, but need to compare to the stable version 2.1.0 when testing for native protocol compatibility, etc.
public int compareTo(VersionNumber other)
compareTo
in interface Comparable<VersionNumber>
Copyright © 2012–2024. All rights reserved.