@Immutable public class Version extends Object implements Comparable<Version>, Serializable
It is in the form X.Y.Z, with optional pre-release labels and build metadata.
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.
Modifier and Type | Field and Description |
---|---|
static Version |
V2_1_0 |
static Version |
V2_2_0 |
static Version |
V3_0_0 |
static Version |
V4_0_0 |
static Version |
V5_0_0 |
static Version |
V6_7_0 |
static Version |
V6_8_0 |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Version 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() |
Version |
nextStable()
The next stable version, i.e.
|
static Version |
parse(String version)
Parses a version from a string.
|
String |
toString() |
@NonNull public static final Version V2_1_0
@NonNull public static final Version V2_2_0
@NonNull public static final Version V3_0_0
@NonNull public static final Version V4_0_0
@NonNull public static final Version V5_0_0
@NonNull public static final Version V6_7_0
@NonNull public static final Version V6_8_0
@Nullable public static Version parse(@Nullable 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 parse.IllegalArgumentException
- 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 returns that fourth number.
public List<String> getPreReleaseLabels()
null
if the version number
doesn't have any.public String getBuildLabel()
null
if the version number doesn't have one.public Version 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(@NonNull Version other)
compareTo
in interface Comparable<Version>
Copyright © 2017–2021. All rights reserved.