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.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(VersionNumber other) |
boolean |
equals(Object o) |
int |
getMajor()
The major version number.
|
int |
getMinor()
The minor version number.
|
int |
getPatch()
The patch version number.
|
String |
getPreReleaseLabel()
The pre-release label if relevant, i.e.
|
int |
hashCode() |
static VersionNumber |
parse(String version)
Parse a version from a string (of the form X.Y.Z[-label]).
|
String |
toString() |
public static VersionNumber parse(String version)
We also parse shorter versions like X.Y[-label] for convenience, but this parse the same as X.Y.0[-label].
version
- the string to parseIllegalArgumentException
- if the provided string does not
represent a valid versionpublic int getMajor()
public int getMinor()
public int getPatch()
public String getPreReleaseLabel()
null
if the version number
doesn't have one.public int compareTo(VersionNumber other)
compareTo
in interface Comparable<VersionNumber>
Copyright © 2014. All rights reserved.