Package com.clickhouse.data
Class ClickHouseVersion
java.lang.Object
com.clickhouse.data.ClickHouseVersion
- All Implemented Interfaces:
Serializable,Comparable<ClickHouseVersion>
public final class ClickHouseVersion
extends Object
implements Comparable<ClickHouseVersion>, Serializable
Immutable ClickHouse version, which takes the form
Year(Major).Feature(Minor).Maintenance(Patch).Build. Prefix like 'v'
and suffix like '-[testing|stable|lts]' will be ignored in parsing and
comparison.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClickHouseVersion(boolean latest, int year, int feature, int maintenance, int build) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbelongsTo(ClickHouseVersion version) Checks if the version belongs to the given series.booleanChecks if the version belongs to the given series.booleanChecks if the version is valid according to the given maven-like version range.static booleanChecks if the version is valid according to the given maven-like version range.static intCompares two versions part by part, which is not semantical.intprotected intcompareTo(ClickHouseVersion o, boolean sameSeriesComparison) Compares current version and the given one.booleanintGets build number.intGets feature release.intGets maintenance release.intGets major version in semantic versioning.intGets minor version in semantic versioning.intgetPatch()Gets patch in semantic versioning.intgetYear()Gets year number.inthashCode()booleanisLatest()Checks if the version is latest or not.booleanisNewerOrEqualTo(ClickHouseVersion version) Checks if the version is newer or equal to the given one.booleanisNewerOrEqualTo(String version) Checks if the version is newer or equal to the given one.booleanisNewerThan(ClickHouseVersion version) Checks if the version is newer than the given one.booleanisNewerThan(String version) Checks if the version is newer than the given one.booleanisOlderOrEqualTo(ClickHouseVersion version) Checks if the version is older or equal to the given one.booleanisOlderOrEqualTo(String version) Checks if the version is older or equal to the given one.booleanisOlderThan(ClickHouseVersion version) Checks if the version is older than the given one.booleanisOlderThan(String version) Checks if the version is older than the given one.static ClickHouseVersionof(int yearOrMajor, int... more) Creates a new version object using given numbers.static ClickHouseVersionParses the given string to extract version.protected static ClickHouseVersionparseVersion(String version) Parses given version without caching.toString()
-
Constructor Details
-
ClickHouseVersion
protected ClickHouseVersion(boolean latest, int year, int feature, int maintenance, int build)
-
-
Method Details
-
check
Checks if the version is valid according to the given maven-like version range. For examples:21.321.3.x.x, short version of [21.3,21.4)[21.3,21.4)21.3.x.x (included) to 21.4.x.x (not included)[21.3,21.4]21.3.x.x to 21.4.x.x (both included)[21.3,)21.3.x.x or higher(,21.3],[21.8,)to 21.3.x.x (included) and 21.8.x.x or higher
- Parameters:
version- version, null is treated as0.0.0.0range- maven-like version range, null or empty means always invalid- Returns:
- true if the version is valid; false otherwise
-
compare
Compares two versions part by part, which is not semantical. For example:compare("21.3.1", "21.3") > 0, because "21.3.1.0" is greater than "21.3.0.0". However,check("21.3.1", "(,21.3]") == true, since "21.3.1" is considered as part of "21.3" series.- Parameters:
fromVersion- versiontoVersion- version to compare with- Returns:
- positive integer if
fromVersionis newer thantoVersion; zero if they're equal; or negative integer iffromVersionis older
-
of
Parses the given string to extract version. Behind the scene, cache is used to avoid unnecessary overhead.- Parameters:
version- version, null or empty string is treated as0.0.0.0- Returns:
- parsed version
-
of
Creates a new version object using given numbers.- Parameters:
yearOrMajor- year or major vrsionmore- more version numbers if any- Returns:
- version
-
parseVersion
Parses given version without caching.- Parameters:
version- version, null or empty string is treated as0.0.0.0- Returns:
- parsed version
-
compareTo
Compares current version and the given one. WhenincludeEmptyPartsistrue, this method returns 0(instead of 1) when comparing '21.3.1.2' with '21.3', because they're in the same series of '21.3'.- Parameters:
o- the object to be comparedsameSeriesComparison- whether compare if two version are in same series- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
-
belongsTo
Checks if the version belongs to the given series. For example: 21.3.1.1 belongs to 21.3 series but not 21.4 or 21.3.2.- Parameters:
version- version series, null will be treated as0.0.0.0- Returns:
- true if the version belongs to the given series; false otherwise
-
belongsTo
Checks if the version belongs to the given series. For example: 21.3.1.1 belongs to 21.3 series but not 21.4 or 21.3.2.- Parameters:
version- version series- Returns:
- true if the version belongs to the given series; false otherwise
-
isLatest
public boolean isLatest()Checks if the version is latest or not.- Returns:
- true if it's latest; false otherwise
-
getYear
public int getYear()Gets year number.- Returns:
- year number
-
getFeatureRelease
public int getFeatureRelease()Gets feature release.- Returns:
- feature release
-
getMaintenanceRelease
public int getMaintenanceRelease()Gets maintenance release.- Returns:
- maintenance release
-
getBuilderNumber
public int getBuilderNumber()Gets build number.- Returns:
- build number
-
getMajorVersion
public int getMajorVersion()Gets major version in semantic versioning. Same asgetYear().- Returns:
- major version
-
getMinorVersion
public int getMinorVersion()Gets minor version in semantic versioning. Same asgetFeatureRelease().- Returns:
- minor version
-
getPatch
public int getPatch()Gets patch in semantic versioning. Same agetMaintenanceRelease().- Returns:
- patch
-
isNewerOrEqualTo
Checks if the version is newer or equal to the given one. Pay attention that when comparing "21.3.1.1" to "21.3",compareTo(ClickHouseVersion)says the former is greater, but this method will return false(because 21.3.x.x still belongs to 21.3 series).- Parameters:
version- version to compare- Returns:
- true if the version is newer or equal to the given one; false otherwise
-
isNewerOrEqualTo
Checks if the version is newer or equal to the given one. Pay attention that when comparing "21.3.1.1" to "21.3",compareTo(ClickHouseVersion)says the former is greater, but this method will return false(because 21.3.x.x still belongs to 21.3 series).- Parameters:
version- version to compare- Returns:
- true if the version is newer or equal to the given one; false otherwise
-
isNewerThan
Checks if the version is newer than the given one. Same ascompareTo(version) > 0.- Parameters:
version- version to compare- Returns:
- true if the version is newer than the given one; false otherwise
-
isNewerThan
Checks if the version is newer than the given one. Same ascompareTo(version) > 0.- Parameters:
version- version to compare- Returns:
- true if the version is newer than the given one; false otherwise
-
isOlderOrEqualTo
Checks if the version is older or equal to the given one. Pay attention that when comparing "21.3.1.1" to "21.3",compareTo(ClickHouseVersion)says the former is greater, but this method will return true(because 21.3.x.x still belongs to 21.3 series).- Parameters:
version- version to compare- Returns:
- true if the version is older or equal to the given one; false otherwise
-
isOlderOrEqualTo
Checks if the version is older or equal to the given one. Pay attention that when comparing "21.3.1.1" to "21.3",compareTo(ClickHouseVersion)says the former is greater, but this method will return true(because 21.3.x.x still belongs to 21.3 series).- Parameters:
version- version to compare- Returns:
- true if the version is older or equal to the given one; false otherwise
-
isOlderThan
Checks if the version is older than the given one. Same ascompareTo(version) < 0.- Parameters:
version- version to compare- Returns:
- true if the version is older than the given one; false otherwise
-
isOlderThan
Checks if the version is older than the given one. Same ascompareTo(version) < 0.- Parameters:
version- version to compare- Returns:
- true if the version is older than the given one; false otherwise
-
check
Checks if the version is valid according to the given maven-like version range.- Parameters:
range- version range, null or empty string means always invalid- Returns:
- true if the version is valid; false otherwise
-
compareTo
- Specified by:
compareToin interfaceComparable<ClickHouseVersion>
-
equals
-
hashCode
public int hashCode() -
toString
-