com.hazelcast.core

## Class PartitionAwareKey<K,P>

- java.lang.Object
- - com.hazelcast.core.PartitionAwareKey<K,P>

- Type Parameters:
    `K` -
    `P` -
  All Implemented Interfaces:
    PartitionAware<Object>, DataSerializable

      public final class PartitionAwareKey<K,P>
      extends Object
      implements PartitionAware<Object>, DataSerializable

  A `PartitionAware` key. This is useful in combination with a Map where you want to control the partition of a key.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PartitionAwareKey(K key, P partitionKey)` Creates a new PartitionAwareKey.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object thatObject)`
    `K` | `getKey()` Gets the key (not the partitionKey).
    `P` | `getPartitionKey()` The key that will be used by Hazelcast to specify the partition.
    `int` | `hashCode()`
    `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`

- - ### Constructor Detail

    - #### PartitionAwareKey

          public PartitionAwareKey(K key,
                                   P partitionKey)

      Creates a new PartitionAwareKey.
      Parameters:
        `key` - the key
        `partitionKey` - the partitionKey
      Throws:
        `IllegalArgumentException` - if key or partitionKey is null.

  - ### Method Detail

    - #### getKey

          public K getKey()

      Gets the key (not the partitionKey).
      Returns:
        the key (not the partitionKey)

    - #### getPartitionKey

          public P getPartitionKey()

      Description copied from interface: `PartitionAware`
      The key that will be used by Hazelcast to specify the partition. You should give the same key for objects that you want to be in the same partition.
      Specified by:
        `getPartitionKey` in interface `PartitionAware<Object>`
      Returns:
        the key that specifies the partition

    - #### 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.

    - #### equals

          public boolean equals(Object thatObject)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2018. All rights reserved.