public final class VersionNumber extends Object implements Comparable<VersionNumber>
Modifier and Type | Class and Description |
---|---|
static class |
VersionNumber.LevelType
Type of the release: alpha, beta, release candidate or patch.
|
Modifier and Type | Field and Description |
---|---|
int |
level
Alpha, beta, release candidate or patch level.
|
VersionNumber.LevelType |
levelType
Type of the release: alpha, beta, release candidate or patch.
|
int |
major
Major version number.
|
int |
micro
Micro version number.
|
static VersionNumber |
MIN_VERSION_NUMBER
Minimal version number: 0.0.0-alpha00.
|
int |
minor
Minor version number.
|
Constructor and Description |
---|
VersionNumber()
Constructs a minimal version number: 0.0.0-alpha00.
|
VersionNumber(int major,
int minor,
int micro)
Constructs version number major.minor.micro.
|
VersionNumber(int major,
int minor,
int micro,
int patch)
Constructs version number
major.minor.micro_patch.
|
VersionNumber(int major,
int minor,
int micro,
VersionNumber.LevelType levelType,
int level)
Constructs version number major.minor.micro
(-alpha|-beta|-rc|_)level.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(VersionNumber other) |
boolean |
equals(Object other) |
static VersionNumber |
fromString(String s)
Equivalent to
fromString(s, false) . |
static VersionNumber |
fromString(String s,
boolean lenient)
Parses specified string as a version number.
|
int |
hashCode() |
VersionNumber |
noLevel()
Returns a copy of this VersionNumber but with all level info (alpha,
beta, release candidate, patch) cleared.
|
static void |
parse(String s,
VersionNumber version)
Parses specified string and returns the result in the specified version
number object.
|
String |
toString()
Returns a string having the following format:
major.minor.micro
if this version number is not an alpha, beta, Release candidate
or patch release.
|
public int major
public int minor
public int micro
public VersionNumber.LevelType levelType
public int level
public static final VersionNumber MIN_VERSION_NUMBER
public VersionNumber()
MIN_VERSION_NUMBER
public VersionNumber(int major, int minor, int micro)
public VersionNumber(int major, int minor, int micro, int patch)
public VersionNumber(int major, int minor, int micro, VersionNumber.LevelType levelType, int level)
public static VersionNumber fromString(String s)
fromString(s, false)
.public static VersionNumber fromString(String s, boolean lenient)
s
- string to be parsedlenient
- if true
, any string starting with
"\d+(\.\d+)?(\.\d+)?(_\d+)?" will be successfully parsed.null
if it cannot be
parsed.public static void parse(String s, VersionNumber version) throws IllegalArgumentException
s
- string to be parsedversion
- the parsed version number is stored in this objectIllegalArgumentException
- if s cannot be parsedpublic VersionNumber noLevel()
public int compareTo(VersionNumber other)
compareTo
in interface Comparable<VersionNumber>
public String toString()