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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Version` | `UNKNOWN` Version 0.0 is UNKNOWN constant
    `static byte` | `UNKNOWN_VERSION` Use 0 as major & minor values for UNKNOWN version

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Version()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(Version o)`
    `boolean` | `equals(Object o)`
    `int` | `getFactoryId()` Returns DataSerializableFactory factory ID for this class.
    `int` | `getId()` Returns type identifier for this class.
    `byte` | `getMajor()`
    `byte` | `getMinor()`
    `int` | `hashCode()`
    `boolean` | `isBetween(Version from, Version to)` Checks if the version is between specified version (both ends inclusive)
    `boolean` | `isEqualTo(Version version)`
    `boolean` | `isGreaterOrEqual(Version version)`
    `boolean` | `isGreaterThan(Version version)`
    `boolean` | `isLessOrEqual(Version version)`
    `boolean` | `isLessThan(Version version)`
    `boolean` | `isUnknown()`
    `boolean` | `isUnknownOrGreaterOrEqual(Version version)`
    `boolean` | `isUnknownOrGreaterThan(Version version)`
    `boolean` | `isUnknownOrLessOrEqual(Version version)`
    `boolean` | `isUnknownOrLessThan(Version version)`
    `static Version` | `of(int major, int minor)`
    `static Version` | `of(String version)` Parse the given string to a `Version`.
    `void` | `readData(ObjectDataInput in)` Reads fields from the input stream
    `String` | `toString()`
    `void` | `writeData(ObjectDataOutput out)` Writes object fields to output stream

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### UNKNOWN_VERSION

          public static final byte UNKNOWN_VERSION

      Use 0 as major & minor values for UNKNOWN version
      See Also:
        Constant Field Values

    - #### UNKNOWN

          public static final Version UNKNOWN

      Version 0.0 is UNKNOWN constant

      - UNKNOWN is only equal to itself.
      - `is(Less|Greater)Than` method with an UNKNOWN operand returns false.
      - `is(Less|Greater)OrEqual` with an UNKNOWN operand returns false, unless both operands are UNKNOWN.
      - `UNKNOWN.isUnknown(Less|Greater)(Than|OrEqual)` returns true.
      - `otherVersion.isUnknown(Less|Greater)(Than|OrEqual)` with an UNKNOWN argument returns false.

  - ### Constructor Detail

    - #### Version

          public Version()

  - ### Method Detail

    - #### getMajor

          public byte getMajor()

    - #### getMinor

          public byte getMinor()

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### writeData

          public void writeData(ObjectDataOutput out)
                         throws IOException

      Description copied from interface: `DataSerializable`
      Writes object fields to output stream
      Specified by:
        `writeData` in interface `DataSerializable`
      Parameters:
        `out` - output
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the output stream has been closed.

    - #### readData

          public void readData(ObjectDataInput in)
                        throws IOException

      Description copied from interface: `DataSerializable`
      Reads fields from the input stream
      Specified by:
        `readData` in interface `DataSerializable`
      Parameters:
        `in` - input
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the input stream has been closed.

    - #### compareTo

          public int compareTo(Version o)

      Specified by:
        `compareTo` in interface `Comparable<Version>`

    - #### getFactoryId

          public int getFactoryId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns DataSerializableFactory factory ID for this class.
      Specified by:
        `getFactoryId` in interface `IdentifiedDataSerializable`
      Returns:
        factory ID

    - #### getId

          public int getId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns type identifier for this class. It should be unique per DataSerializableFactory.
      Specified by:
        `getId` in interface `IdentifiedDataSerializable`
      Returns:
        type ID

    - #### of

          public static Version of(int major,
                                   int minor)

      Returns:
        the `ClusterVersion` with the given major and minor

    - #### of

          public static Version of(String version)

      Parse the given string to a `Version`. This method may throw an `IllegalArgumentException`
      Parameters:
        `version` - string to parse to `Version`.
      Returns:
        the `Version` parsed from given argument.

    - #### isEqualTo

          public boolean isEqualTo(Version version)

      Parameters:
        `version` - other version to compare to
      Returns:
        `true` if this version equals `version`

    - #### isGreaterThan

          public boolean isGreaterThan(Version version)

      Parameters:
        `version` - other version to compare to
      Returns:
        `true` if this version is greater than `version`

    - #### isUnknownOrGreaterThan

          public boolean isUnknownOrGreaterThan(Version version)

      Parameters:
        `version` - other version to compare to
      Returns:
        `true` if this version is unknown or if this version is greater than `version`

    - #### isGreaterOrEqual

          public boolean isGreaterOrEqual(Version version)

      Parameters:
        `version` - other version to compare to
      Returns:
        `true` if this version is greater than or equal to `version`

    - #### isUnknownOrGreaterOrEqual

          public boolean isUnknownOrGreaterOrEqual(Version version)

      Parameters:
        `version` - other version to compare to
      Returns:
        `true` if this version is unknown or if this version is greater than or equal to `version`

    - #### isLessThan

          public boolean isLessThan(Version version)

      Parameters:
        `version` - other version to compare to
      Returns:
        `true` if this version is less than `version`

    - #### isUnknownOrLessThan

          public boolean isUnknownOrLessThan(Version version)

      Parameters:
        `version` - other version to compare to
      Returns:
        `true` if this version is unknown or if this version is less than `version`

    - #### isLessOrEqual

          public boolean isLessOrEqual(Version version)

      Parameters:
        `version` - other version to compare to
      Returns:
        `true` if this version is less than or equal to `version`

    - #### isUnknownOrLessOrEqual

          public boolean isUnknownOrLessOrEqual(Version version)

      Parameters:
        `version` - other version to compare to
      Returns:
        `true` if this version is unknown or if this version is less than or equal to `version`

    - #### isBetween

          public boolean isBetween(Version from,
                                   Version to)

      Checks if the version is between specified version (both ends inclusive)
      Parameters:
        `from` -
        `to` -
      Returns:
        true if the version is between from and to (both ends inclusive)

    - #### isUnknown

          public boolean isUnknown()

      Returns:
        `true` if this version is equal to `UNKNOWN`

Copyright © 2018. All rights reserved.