public final class Version extends Object implements Serializable, Comparable<Version>
MAJOR.MINOR.PATCH.QUALIFIER where the qualifier can have an extra version.
For example: 1.2.0.RC1 is the first release candidate of 1.2.0 and
1.5.0.M4 is the fourth milestone of 1.5.0. The special RELEASE
qualifier indicates a final release (a.k.a. GA)
The main purpose of parsing a version is to compare it with another version, see
Comparable.
| Modifier and Type | Class and Description |
|---|---|
static class |
Version.Qualifier
A version qualifier.
|
| Constructor and Description |
|---|
Version(Integer major,
Integer minor,
Integer patch,
Version.Qualifier qualifier) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Version other) |
boolean |
equals(Object obj) |
Integer |
getMajor() |
Integer |
getMinor() |
Integer |
getPatch() |
Version.Qualifier |
getQualifier() |
int |
hashCode() |
static Version |
parse(String text)
Parse the string representation of a
Version. |
static Version |
safeParse(String text)
Parse safely the specified string representation of a
Version. |
String |
toString() |
public Version(Integer major, Integer minor, Integer patch, Version.Qualifier qualifier)
public Integer getMajor()
public Integer getMinor()
public Integer getPatch()
public Version.Qualifier getQualifier()
public static Version parse(String text)
Version. Throws an
InvalidVersionException if the version could not be parsed.text - the version textInvalidVersionException - if the version text could not be parsedVersionParserpublic static Version safeParse(String text)
Version.
Return null if the text represents an invalid version.
text - the version textVersionParserpublic int compareTo(Version other)
compareTo in interface Comparable<Version>Copyright © 2019 Pivotal Software, Inc.. All rights reserved.