Class SingleFieldId<T,​S extends SingleFieldId>

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, java.lang.Comparable<S>
    Direct Known Subclasses:
    ByteId, CharId, IntId, LongId, ObjectId, ShortId, StringId

    public abstract class SingleFieldId<T,​S extends SingleFieldId>
    extends java.lang.Object
    implements java.io.Externalizable, java.lang.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:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int hashCode  
      protected static java.lang.String STRING_DELIMITER  
      protected java.lang.String targetClassName
      The name of the class of the target persistable object.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        SingleFieldId()  
      protected SingleFieldId​(java.lang.Class<?> pcClass)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void assertKeyNotNull​(java.lang.Object key)
      Assert that the key is not null.
      protected int compare​(S o)
      Determine the ordering of identity objects.
      boolean equals​(java.lang.Object obj)  
      abstract T getKeyAsObject()
      Accessor for the key
      java.lang.String getTargetClassName()
      Accessor for the target class name
      int hashCode()  
      protected abstract boolean keyEquals​(S other)  
      void readExternal​(java.io.ObjectInput in)
      Read from the input stream.
      void writeExternal​(java.io.ObjectOutput out)
      Write to the output stream.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Comparable

        compareTo
    • Field Detail

      • STRING_DELIMITER

        protected static final java.lang.String STRING_DELIMITER
        See Also:
        Constant Field Values
      • targetClassName

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

        protected int hashCode
    • Constructor Detail

      • SingleFieldId

        protected SingleFieldId​(java.lang.Class<?> pcClass)
      • SingleFieldId

        public SingleFieldId()
    • Method Detail

      • assertKeyNotNull

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

        public java.lang.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​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • keyEquals

        protected abstract boolean keyEquals​(S other)
      • hashCode

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

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

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Read from the input stream. Creates a new instance with the target class name set
        Specified by:
        readExternal in interface java.io.Externalizable
        Parameters:
        in - Input object
        Throws:
        java.io.IOException
        java.lang.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