Class Version
- All Implemented Interfaces:
Comparable<Version>
Version consists of three components
- Major version. A non-negative integer.
- Minor version. A non-negative integer.
- Micro version. A non-negative integer.
Version
objects are immutable.
- Restriction:
- This class is not intended to be subclassed by clients.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Version
The empty version "0.0.0".static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
static final Version
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Compares thisVersion
object to anotherVersion
.static Version
Parses a version identifier from the specified string.boolean
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.int
hashCode()
boolean
isGreaterThan
(Version that) Compares that thisVersion
object is greater than specifiedVersion
objectboolean
Checks if given version is in specified version range and false otherwise.boolean
isLessThan
(Version that) Compares that thisVersion
object is less than specifiedVersion
objectstatic Version
ParseCompatibilityMode
to platfromVersion
.static Version
parseVersion
(String version) Parses a version identifier from the specified string.toString()
-
Field Details
-
V8_3_6
-
V8_3_7
-
V8_3_8
-
V8_3_9
-
V8_3_10
-
V8_3_11
-
V8_3_12
-
V8_3_13
-
V8_3_14
-
V8_3_15
-
V8_3_16
-
V8_3_17
-
V8_3_18
-
V8_3_19
-
V8_3_20
-
V8_3_21
-
V8_3_22
-
V8_3_23
-
V8_3_24
-
V8_3_25
-
V8_3_26
-
V8_3_27
-
LATEST
-
EMPTY_VERSION
The empty version "0.0.0".
-
-
Constructor Details
-
Version
public Version(int major, int minor, int micro) Creates a version identifier from the specified numerical components.- Parameters:
major
- Major component of the version identifier, not negative.minor
- Minor component of the version identifier, not negative.micro
- Micro component of the version identifier, not negative.- Throws:
IllegalArgumentException
- If the numerical components are negative.
-
Version
Creates a version identifier from the specified string.Version string grammar:
version ::= major('.'minor('.'micro)?)? major ::= digit+ minor ::= digit+ micro ::= digit+ digit ::= [0..9]
- Parameters:
version
- String representation of the version identifier. There must be no whitespace in the argument.- Throws:
IllegalArgumentException
- Ifversion
is improperly formatted.
-
-
Method Details
-
parseCompatibilityMode
ParseCompatibilityMode
to platfromVersion
. It will be equals to compatibility mode version.- Parameters:
mode
- the compatibility mode to parseVersion
from, cannot benull
- Returns:
- parsed
Version
, nevernull
-
parseVersion
Parses a version identifier from the specified string.See
Version(String)
for the format of the version string.- Parameters:
version
- String representation of the version identifier. Leading and trailing whitespace will be ignored.- Returns:
- A
Version
object representing the version identifier. Ifversion
isnull
or the empty string thenEMPTY_VERSION
will be returned. - Throws:
IllegalArgumentException
- Ifversion
is improperly formatted.
-
create
Parses a version identifier from the specified string.Version string grammar:
version ::= 'major.minor.micro' major ::= digit+ minor ::= digit+ micro ::= digit+ digit ::= [0..9]
See
Version(String)
for the format of the version string.- Parameters:
version
- String representation of the version identifier. Leading and trailing whitespace will be ignored.- Returns:
- A
Version
object representing the version identifier. Ifversion
isnull
or the empty string thennull
will be returned.
ifversion
has illegal formatnull
will be returned.
-
isInRange
Checks if given version is in specified version range and false otherwise.Version range string grammar
range ::= ('['|'(')version(, version)?(']'|')') version ::= major('.'minor('.'micro)?)? major ::= digit+ minor ::= digit+ micro ::= digit+ digit ::= [0..9]
Example usage:
Version version = ... if (version.isInRange("[8.3.2, 8.3.5)")) // do something
- Parameters:
versionRange
- the version range (notnull
).- Returns:
- true when given version is in specified version range and false otherwise.
- Throws:
IllegalArgumentException
- If versionRange is improperly formatted.
-
isGreaterThan
Compares that thisVersion
object is greater than specifiedVersion
object- Parameters:
that
- TheVersion
object to be compared, notnull
- Returns:
true
if this version is greater than the specifiedVersion
object,false
in otherwise
-
isLessThan
Compares that thisVersion
object is less than specifiedVersion
object- Parameters:
that
- TheVersion
object to be compared, notnull
- Returns:
true
if this version is less than the specifiedVersion
object,false
in otherwise
-
getMajor
public int getMajor()Returns the major component of this version identifier.- Returns:
- The major component.
-
getMinor
public int getMinor()Returns the minor component of this version identifier.- Returns:
- The minor component.
-
getMicro
public int getMicro()Returns the micro component of this version identifier.- Returns:
- The micro component.
-
compareTo
Compares thisVersion
object to anotherVersion
.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.
A version is considered to be equal to another version if the major, minor and micro components are equal.
- Specified by:
compareTo
in interfaceComparable<Version>
- Parameters:
other
- TheVersion
object to be compared, notnull
- Returns:
- A negative integer, zero, or a positive integer if this version
is less than, equal to, or greater than the specified
Version
object. - Throws:
ClassCastException
- If the specified object is not aVersion
object.
-
toString
-
equals
-
hashCode
public int hashCode()
-