Class CacheId

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CacheId>

    public class CacheId
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable<CacheId>
    Defines a wrapper for a primary key (Id) to use as a key in the cache.
    Since:
    EclipseLink 2.1
    Author:
    James Sutherland
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static CacheId EMPTY  
      protected boolean hasArray
      Indicates whether at least one element of primaryKey is array.
      protected int hash
      Cached hashcode.
      protected java.lang.Object[] primaryKey
      The primary key values.
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheId()  
      CacheId​(java.lang.Object[] primaryKey)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.Object value)
      Append the value to the end of the primary key values.
      int compareTo​(CacheId otherId)
      Determine if the receiver is greater or less than the key.
      protected int computeHash​(java.lang.Object[] primaryKey)
      Pre-compute the hash to optimize hash calls.
      boolean equals​(java.lang.Object object)
      Determine if the receiver is equal to anObject.
      boolean equals​(CacheId id)
      Determine if the receiver is equal to key.
      java.lang.Object[] getPrimaryKey()  
      boolean hasArray()  
      int hashCode()
      Return the precomputed hashcode.
      void set​(int index, java.lang.Object value)
      Set the value in the primary key values.
      void setPrimaryKey​(java.lang.Object[] primaryKey)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • EMPTY

        public static final CacheId EMPTY
      • primaryKey

        protected java.lang.Object[] primaryKey
        The primary key values.
      • hash

        protected int hash
        Cached hashcode.
      • hasArray

        protected boolean hasArray
        Indicates whether at least one element of primaryKey is array.
    • Constructor Detail

      • CacheId

        public CacheId()
      • CacheId

        public CacheId​(java.lang.Object[] primaryKey)
    • Method Detail

      • getPrimaryKey

        public java.lang.Object[] getPrimaryKey()
      • setPrimaryKey

        public void setPrimaryKey​(java.lang.Object[] primaryKey)
      • add

        public void add​(java.lang.Object value)
        Append the value to the end of the primary key values.
      • set

        public void set​(int index,
                        java.lang.Object value)
        Set the value in the primary key values.
      • computeHash

        protected int computeHash​(java.lang.Object[] primaryKey)
        Pre-compute the hash to optimize hash calls.
      • hashCode

        public int hashCode()
        Return the precomputed hashcode.
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object object)
        Determine if the receiver is equal to anObject. If anObject is a CacheKey, do further comparison, otherwise, return false.
        Overrides:
        equals in class java.lang.Object
        See Also:
        CacheKey.equals(CacheKey)
      • equals

        public boolean equals​(CacheId id)
        Determine if the receiver is equal to key. Use an index compare, because it is much faster than enumerations.
      • compareTo

        public int compareTo​(CacheId otherId)
        Determine if the receiver is greater or less than the key.
        Specified by:
        compareTo in interface java.lang.Comparable<CacheId>
      • hasArray

        public boolean hasArray()
      • toString

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