edu.northwestern.at.utils

## Class CompoundKey

- java.lang.Object
- - edu.northwestern.at.utils.CompoundKey

- All Implemented Interfaces:
    XCloneable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

      public class CompoundKey
      extends java.lang.Object
      implements XCloneable, java.lang.Comparable, java.io.Serializable

  A compound key class for collections.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.Comparable[]` | `keyValues` Object array of key values.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CompoundKey(java.lang.Comparable row)` Create a CompoundKey with one value.
    `CompoundKey(java.lang.Comparable[] keyValues)` Create a CompoundKey.
    `CompoundKey(java.lang.Comparable row, java.lang.Comparable column)` Create a CompoundKey with two values.
    `CompoundKey(java.lang.Comparable row, java.lang.Comparable column, java.lang.Comparable slice)` Create a CompoundKey with two values.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `clone()` Return a shallow cloned copy of this object.
    `int` | `compareTo(java.lang.Object object)` Compare this key with another.
    `boolean` | `equals(java.lang.Object object)` Check if another object is equal to this one.
    `java.lang.Comparable[]` | `getKeyValues()` Get key values.
    `int` | `hashCode()` Get the hash code of the keys.
    `java.lang.String` | `toString()` Return a string representation of this object.

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

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

- - ### Field Detail

    - #### keyValues

          protected final java.lang.Comparable[] keyValues

      Object array of key values. Key values should be simple objects.

      The key value is declared final because its values should not be changed once it is defined.

  - ### Constructor Detail

    - #### CompoundKey

          public CompoundKey(java.lang.Comparable[] keyValues)

      Create a CompoundKey.
      Parameters:
        `keyValues` - Values of the key as an array.

        Each key value must implement the comparable interface.

    - #### CompoundKey

          public CompoundKey(java.lang.Comparable row)

      Create a CompoundKey with one value.
      Parameters:
        `row` - "Row" value.

    - #### CompoundKey

          public CompoundKey(java.lang.Comparable row,
                     java.lang.Comparable column)

      Create a CompoundKey with two values.
      Parameters:
        `row` - "Row" value.
        `column` - "Column" value.

    - #### CompoundKey

          public CompoundKey(java.lang.Comparable row,
                     java.lang.Comparable column,
                     java.lang.Comparable slice)

      Create a CompoundKey with two values.
      Parameters:
        `row` - "Row" value.
        `column` - "Column" value.
        `slice` - "Slice" value.

  - ### Method Detail

    - #### equals

          public boolean equals(java.lang.Object object)

      Check if another object is equal to this one.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `object` - Other object to test for equality.
      Returns:
        true if other object is equal to this one.

    - #### compareTo

          public int compareTo(java.lang.Object object)

      Compare this key with another.
      Specified by:
        `compareTo` in interface `java.lang.Comparable`
      Parameters:
        `object` - The other CompoundKey.
      Returns:
        > 0 if the other key is less than this one, = 0 if the two keys are equal, < 0 if the other key is greater than this one.

        We use compareTo on the array entries in the key. This may not give the desired result if the array entries are themselves arrays.

    - #### hashCode

          public int hashCode()

      Get the hash code of the keys.
      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        The hash code.

    - #### toString

          public java.lang.String toString()

      Return a string representation of this object.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        A string representation of this object.

    - #### getKeyValues

          public java.lang.Comparable[] getKeyValues()

      Get key values.
      Returns:
        Object array of key values.

    - #### clone

          public java.lang.Object clone()

      Return a shallow cloned copy of this object.
      Specified by:
        `clone` in interface `XCloneable`
      Overrides:
        `clone` in class `java.lang.Object`
      Returns:
        Shallow clone of this object.
      Throws:
        `java.lang.CloneNotSupportedException` - which should never happen.