Class PartitionAwareKey<K,​P>

  • Type Parameters:
    K - the key type
    P - the partitionKey type
    All Implemented Interfaces:
    DataSerializable, PartitionAware<java.lang.Object>

    public final class PartitionAwareKey<K,​P>
    extends java.lang.Object
    implements PartitionAware<java.lang.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 Description
      PartitionAwareKey​(K key, P partitionKey)
      Creates a new PartitionAwareKey.
    • Constructor Detail

      • PartitionAwareKey

        public PartitionAwareKey​(K key,
                                 P partitionKey)
        Creates a new PartitionAwareKey.
        Parameters:
        key - the key
        partitionKey - the partitionKey
        Throws:
        java.lang.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<K>
        Returns:
        the key that specifies the partition
      • writeData

        public void writeData​(ObjectDataOutput out)
                       throws java.io.IOException
        Description copied from interface: DataSerializable
        Writes object fields to output stream
        Specified by:
        writeData in interface DataSerializable
        Parameters:
        out - output
        Throws:
        java.io.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 java.io.IOException
        Description copied from interface: DataSerializable
        Reads fields from the input stream
        Specified by:
        readData in interface DataSerializable
        Parameters:
        in - input
        Throws:
        java.io.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​(java.lang.Object thatObject)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object