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 VersionThe empty version "0.0.0".static final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Versionstatic final Version -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCompares thisVersionobject to anotherVersion.static VersionParses a version identifier from the specified string.booleanintgetMajor()Returns the major component of this version identifier.intgetMicro()Returns the micro component of this version identifier.intgetMinor()Returns the minor component of this version identifier.inthashCode()booleanisGreaterThan(Version that) Compares that thisVersionobject is greater than specifiedVersionobjectbooleanChecks if given version is in specified version range and false otherwise.booleanisLessThan(Version that) Compares that thisVersionobject is less than specifiedVersionobjectstatic VersionParseCompatibilityModeto platfromVersion.static VersionparseVersion(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- Ifversionis improperly formatted.
-
-
Method Details
-
parseCompatibilityMode
ParseCompatibilityModeto platfromVersion. It will be equals to compatibility mode version.- Parameters:
mode- the compatibility mode to parseVersionfrom, 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
Versionobject representing the version identifier. Ifversionisnullor the empty string thenEMPTY_VERSIONwill be returned. - Throws:
IllegalArgumentException- Ifversionis 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
Versionobject representing the version identifier. Ifversionisnullor the empty string thennullwill be returned.
ifversionhas illegal formatnullwill 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 thisVersionobject is greater than specifiedVersionobject- Parameters:
that- TheVersionobject to be compared, notnull- Returns:
trueif this version is greater than the specifiedVersionobject,falsein otherwise
-
isLessThan
Compares that thisVersionobject is less than specifiedVersionobject- Parameters:
that- TheVersionobject to be compared, notnull- Returns:
trueif this version is less than the specifiedVersionobject,falsein 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 thisVersionobject 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:
compareToin interfaceComparable<Version>- Parameters:
other- TheVersionobject 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
Versionobject. - Throws:
ClassCastException- If the specified object is not aVersionobject.
-
toString
-
equals
-
hashCode
public int hashCode()
-