Class SingleFieldId<T,S extends SingleFieldId>

java.lang.Object
org.datanucleus.identity.SingleFieldId<T,S>
All Implemented Interfaces:
Externalizable, Serializable, Comparable<S>
Direct Known Subclasses:
ByteId, CharId, IntId, LongId, ObjectId, ShortId, StringId

public abstract class SingleFieldId<T,S extends SingleFieldId> extends Object implements Externalizable, Comparable<S>
This class is the abstract base class for all single field identity classes. TODO All subclasses should implement the same rules as applies to all identity classes, namely String constructor taking output of toString(), etc.
See Also:
  • Field Details

    • STRING_DELIMITER

      protected static final String STRING_DELIMITER
      See Also:
    • targetClassName

      protected String targetClassName
      The name of the class of the target persistable object.
    • hashCode

      protected int hashCode
  • Constructor Details

    • SingleFieldId

      protected SingleFieldId(Class<?> pcClass)
    • SingleFieldId

      public SingleFieldId()
  • Method Details

    • assertKeyNotNull

      protected void assertKeyNotNull(Object key)
      Assert that the key is not null. Throw a NucleusUserException if the given key is null.
      Parameters:
      key - The key
    • getTargetClassName

      public String getTargetClassName()
      Accessor for the target class name
      Returns:
      Class name for the object represented by this id
    • getKeyAsObject

      public abstract T getKeyAsObject()
      Accessor for the key
      Returns:
      The key
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • keyEquals

      protected abstract boolean keyEquals(S other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Write to the output stream.
      Specified by:
      writeExternal in interface Externalizable
      Parameters:
      out - the stream
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Read from the input stream. Creates a new instance with the target class name set
      Specified by:
      readExternal in interface Externalizable
      Parameters:
      in - Input object
      Throws:
      IOException
      ClassNotFoundException
    • compare

      protected int compare(S o)
      Determine the ordering of identity objects. Only the class name is compared. This method is only used by subclasses.
      Parameters:
      o - Other identity
      Returns:
      The relative ordering between the objects