Represents a version consisting of major, minor, patch version, and suffix, for example '1.2.7-SNAPSHOT'.
Returns a Version instance created from the given parameters.
This function can either be called as a constructor (using new
) or as a normal function. It always returns an immutable Version instance.
The parts of the version number (major, minor, patch, suffix) can be provided in several ways:
To keep the code size small, this implementation mainly validates the single string variant. All other variants are only validated to some degree. It is the responsibility of the caller to provide proper parts.
new module:sap/base/util/Version(vMajor, iMinor, iPatch, sSuffix)
Param | Type | Default Value | Description |
---|---|---|---|
vMajor | int string any[] module:sap/base/util/Version | the major part of the version (int) or any of the single parameter variants explained above. |
|
iMinor | int | the minor part of the version number |
|
iPatch | int | the patch part of the version number |
|
sSuffix | string | the suffix part of the version number |
Method | Description |
---|---|
compareTo |
Compares this version with a given one. The version with which this version should be compared can be given as a |
getMajor |
Returns the major version part of this version. |
getMinor |
Returns the minor version part of this version. |
getPatch |
Returns the patch (or micro) version part of this version. |
getSuffix |
Returns the version suffix of this version. |
inRange |
Checks whether this version is in the range of the given interval (start inclusive, end exclusive). The boundaries against which this version should be checked can be given as |
toString |
Returns a string representation of this version. |
Compares this version with a given one.
The version with which this version should be compared can be given as a sap/base/util/Version
instance, as a string (e.g. v.compareto("1.4.5")
). Or major, minor, patch and suffix values can be given as separate parameters (e.g. v.compareTo(1, 4, 5)
) or in an array (e.g. v.compareTo([1, 4, 5])
).
Checks whether this version is in the range of the given interval (start inclusive, end exclusive).
The boundaries against which this version should be checked can be given as sap/base/util/Version
instances (e.g. v.inRange(v1, v2)
), as strings (e.g. v.inRange("1.4", "2.7")
) or as arrays (e.g. v.inRange([1,4], [2,7])
).
Param | Type | DefaultValue | Description |
---|---|---|---|
vMin | string any[] module:sap/base/util/Version |
the start of the range (inclusive) |
|
vMax | string any[] module:sap/base/util/Version |
the end of the range (exclusive) |