Class CompoundKey

  • All Implemented Interfaces:
    java.io.Serializable

    public final class CompoundKey
    extends java.lang.Object
    implements java.io.Serializable
    Compound Key - used in IDENTITY FIELD example
    Simple compound key (composite key) implementation following Martin Fowler's approach.
    Author:
    Karl Eilebrecht
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      CompoundKey​(long[] keyFieldValues)
      Creates new compound keys from the given long values
      CompoundKey​(java.io.Serializable... keyFieldValues)
      Creates new compound keys from the given objects
      CompoundKey​(java.util.Collection<? extends java.lang.Object> keyFieldValues)
      Creates new compound keys from the given objects
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.io.Serializable getKeyFieldValueAt​(int idx)
      Returns the value at the specified index
      int getKeyLength()
      Returns the length of the key (number of parts)
      java.io.Serializable getSingleKeyValue()
      Returns the key value if this is a single field key (not a compound key)
      int hashCode()  
      boolean isCompoundKey()
      Returns whether this key has more than one field
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CompoundKey

        public CompoundKey​(java.io.Serializable... keyFieldValues)
        Creates new compound keys from the given objects
        Parameters:
        keyFieldValues - parts of the key
      • CompoundKey

        public CompoundKey​(long[] keyFieldValues)
        Creates new compound keys from the given long values
        Parameters:
        keyFieldValues - parts of the key
      • CompoundKey

        public CompoundKey​(java.util.Collection<? extends java.lang.Object> keyFieldValues)
        Creates new compound keys from the given objects
        Parameters:
        keyFieldValues - parts of the key
    • Method Detail

      • getKeyFieldValueAt

        public java.io.Serializable getKeyFieldValueAt​(int idx)
        Returns the value at the specified index
        Parameters:
        idx - part of the key
        Returns:
        key part
      • getSingleKeyValue

        public java.io.Serializable getSingleKeyValue()
        Returns the key value if this is a single field key (not a compound key)
        Returns:
        key part
      • isCompoundKey

        public boolean isCompoundKey()
        Returns whether this key has more than one field
        Returns:
        true if number of key fields is greater than 1, otherwise false
      • getKeyLength

        public int getKeyLength()
        Returns the length of the key (number of parts)
        Returns:
        number of key fields
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

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