Package com.hazelcast.version
Class Version
java.lang.Object
com.hazelcast.version.Version
- All Implemented Interfaces:
DataSerializable,IdentifiedDataSerializable,Comparable<Version>
public final class Version
extends Object
implements IdentifiedDataSerializable, Comparable<Version>
A generic version to be used with
VersionAware classes. The version is composed of two bytes, denoting
MAJOR.MINOR version. It is used to represent the Hazelcast cluster version and the serialization version of
VersionAware classes.- Since:
- 3.8
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final VersionVersion 0.0 is UNKNOWN constantUNKNOWNis only equal to itself.is(Less|Greater)Thanmethod with anUNKNOWNoperand returns false.is(Less|Greater)OrEqualwith anUNKNOWNoperand returns false, unless both operands areUNKNOWN.UNKNOWN.isUnknown(Less|Greater)(Than|OrEqual)returns true.otherVersion.isUnknown(Less|Greater)(Than|OrEqual)with anUNKNOWNargument returns false.static final byteUse 0 as major & minor values for UNKNOWN version -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanintReturns type identifier for this class.intReturns DataSerializableFactory factory ID for this class.bytegetMajor()bytegetMinor()inthashCode()booleanChecks if the version is between specified version (both ends inclusive)booleanbooleanisGreaterOrEqual(Version version) booleanisGreaterThan(Version version) booleanisLessOrEqual(Version version) booleanisLessThan(Version version) booleanbooleanisUnknownOrGreaterOrEqual(Version version) booleanisUnknownOrGreaterThan(Version version) booleanisUnknownOrLessOrEqual(Version version) booleanisUnknownOrLessThan(Version version) static Versionof(int major, int minor) static VersionParse the given string to aVersion.voidReads fields from the input streamtoString()voidWrites object fields to output stream
-
Field Details
-
UNKNOWN_VERSION
public static final byte UNKNOWN_VERSIONUse 0 as major & minor values for UNKNOWN version- See Also:
-
UNKNOWN
Version 0.0 is UNKNOWN constantUNKNOWNis only equal to itself.is(Less|Greater)Thanmethod with anUNKNOWNoperand returns false.is(Less|Greater)OrEqualwith anUNKNOWNoperand returns false, unless both operands areUNKNOWN.UNKNOWN.isUnknown(Less|Greater)(Than|OrEqual)returns true.otherVersion.isUnknown(Less|Greater)(Than|OrEqual)with anUNKNOWNargument returns false.
-
-
Constructor Details
-
Version
public Version()
-
-
Method Details
-
getMajor
public byte getMajor() -
getMinor
public byte getMinor() -
equals
-
hashCode
public int hashCode() -
toString
-
writeData
Description copied from interface:DataSerializableWrites object fields to output stream- Specified by:
writeDatain interfaceDataSerializable- Parameters:
out- output- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the output stream has been closed.
-
readData
Description copied from interface:DataSerializableReads fields from the input stream- Specified by:
readDatain interfaceDataSerializable- Parameters:
in- input- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the input stream has been closed.
-
compareTo
- Specified by:
compareToin interfaceComparable<Version>
-
getFactoryId
public int getFactoryId()Description copied from interface:IdentifiedDataSerializableReturns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryIdin interfaceIdentifiedDataSerializable- Returns:
- factory ID
-
getClassId
public int getClassId()Description copied from interface:IdentifiedDataSerializableReturns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassIdin interfaceIdentifiedDataSerializable- Returns:
- type ID
-
of
- Returns:
- the
ClusterVersionwith the given major and minor
-
of
Parse the given string to aVersion. This method may throw anIllegalArgumentException- Parameters:
version- string to parse toVersion.- Returns:
- the
Versionparsed from given argument.
-
isEqualTo
- Parameters:
version- other version to compare to- Returns:
trueif this version equalsversion
-
isGreaterThan
- Parameters:
version- other version to compare to- Returns:
trueif this version is greater thanversion
-
isUnknownOrGreaterThan
- Parameters:
version- other version to compare to- Returns:
trueif this version is unknown or if this version is greater thanversion
-
isGreaterOrEqual
- Parameters:
version- other version to compare to- Returns:
trueif this version is greater than or equal toversion
-
isUnknownOrGreaterOrEqual
- Parameters:
version- other version to compare to- Returns:
trueif this version is unknown or if this version is greater than or equal toversion
-
isLessThan
- Parameters:
version- other version to compare to- Returns:
trueif this version is less thanversion
-
isUnknownOrLessThan
- Parameters:
version- other version to compare to- Returns:
trueif this version is unknown or if this version is less thanversion
-
isLessOrEqual
- Parameters:
version- other version to compare to- Returns:
trueif this version is less than or equal toversion
-
isUnknownOrLessOrEqual
- Parameters:
version- other version to compare to- Returns:
trueif this version is unknown or if this version is less than or equal toversion
-
isBetween
Checks if the version is between specified version (both ends inclusive)- Parameters:
from- the lower bound versionto- the upper bound version- Returns:
- true if the version is between from and to (both ends inclusive)
-
isUnknown
public boolean isUnknown()- Returns:
trueif this version is equal toUNKNOWN
-
previousMinor
-