@JsType(namespace="hal.config") public class Version extends Object implements Comparable
Version identifiers have four components.
Version(String) for the
format of the qualifier string.
Version objects are immutable.
| Modifier and Type | Field and Description |
|---|---|
static Version |
EMPTY_VERSION
The empty version "0.0.0".
|
| Constructor and Description |
|---|
Version(int major,
int minor,
int micro)
Creates a version identifier from the specified numerical components.
|
Version(int major,
int minor,
int micro,
String qualifier)
Creates a version identifier from the specifed components.
|
Version(String version)
Created a version identifier from the specified string.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Object object)
Compares this
Version object to another object. |
boolean |
equals(Object object)
Compares this
Version object to another object. |
int |
getMajor()
Returns the major component of this version identifier.
|
int |
getMicro()
Returns the micro component of this version identifier.
|
int |
getMinor()
Returns the minor component of this version identifier.
|
String |
getQualifier()
Returns the qualifier component of this version identifier.
|
boolean |
greaterThan(Version other)
Checks if this version is greater than the other version.
|
boolean |
greaterThanOrEqualTo(Version other)
Checks if this version is greater than or equal to the other version.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
lessThan(Version other)
Checks if this version is less than the other version.
|
boolean |
lessThanOrEqualTo(Version other)
Checks if this version is less than or equal to the other version.
|
static Version |
parseVersion(String version)
Parses a version identifier from the specified string.
|
String |
toString()
Returns the string representation of this version identifier.
|
@JsIgnore public static final Version EMPTY_VERSION
new Version(0,0,0).@JsIgnore
public Version(int major,
int minor,
int micro)
The qualifier is set to the empty string.
major - Major component of the version identifier.minor - Minor component of the version identifier.micro - Micro component of the version identifier.IllegalArgumentException - If the numerical components are
negative.@JsIgnore
public Version(int major,
int minor,
int micro,
String qualifier)
major - Major component of the version identifier.minor - Minor component of the version identifier.micro - Micro component of the version identifier.qualifier - Qualifier component of the version identifier. If
null is specified, then the qualifier will be set
to the empty string.IllegalArgumentException - If the numerical components are negative
or the qualifier string is invalid.@JsIgnore public Version(String version)
Here is the grammar for version strings.
version ::= major('.'minor('.'micro('.'qualifier)?)?)?
major ::= digit+
minor ::= digit+
micro ::= digit+
qualifier ::= (alpha|digit|'_'|'-')+
digit ::= [0..9]
alpha ::= [a..zA..Z]
There must be no whitespace in version.version - String representation of the version identifier.IllegalArgumentException - If version is improperly
formatted.public static Version parseVersion(String version)
See Version(String) for the format of the version string.
version - String representation of the version identifier. Leading
and trailing whitespace will be ignored.Version object representing the version
identifier. If version is null or
the empty string then EMPTY_VERSION will be
returned.IllegalArgumentException - If version is improperly
formatted.public int getMajor()
public int getMinor()
public int getMicro()
public String getQualifier()
@JsIgnore public String toString()
The format of the version string will be major.minor.micro
if qualifier is the empty string or
major.minor.micro.qualifier otherwise.
@JsIgnore public int hashCode()
@JsIgnore public boolean equals(Object object)
Version object to another object.
A version is considered to be equal to another version if the
major, minor and micro components are equal and the qualifier component
is equal (using String.equals).
@JsIgnore public int compareTo(Object object)
Version object to another object.
A version is considered to be less than another version if its
major component is less than the other version's major component, or the
major components are equal and its minor component is less than the other
version's minor component, or the major and minor components are equal
and its micro component is less than the other version's micro component,
or the major, minor and micro components are equal and it's qualifier
component is less than the other version's qualifier component (using
String.compareTo).
A version is considered to be equal to another version if the
major, minor and micro components are equal and the qualifier component
is equal (using String.compareTo).
compareTo in interface Comparableobject - The Version object to be compared.Version object.ClassCastException - If the specified object is not a
Version.@JsIgnore public boolean greaterThan(Version other)
other - the other version to compare totrue if this version is greater than the other version
or false otherwise#compareTo(Version other)@JsIgnore public boolean greaterThanOrEqualTo(Version other)
other - the other version to compare totrue if this version is greater than or equal
to the other version or false otherwise#compareTo(Version other)@JsIgnore public boolean lessThan(Version other)
other - the other version to compare totrue if this version is less than the other version
or false otherwise#compareTo(Version other)@JsIgnore public boolean lessThanOrEqualTo(Version other)
other - the other version to compare totrue if this version is less than or equal
to the other version or false otherwise#compareTo(Version other)Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.