- java.lang.Object
-
- org.datanucleus.identity.SingleFieldId<T>
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Comparable
public abstract class SingleFieldId<T> extends Object implements Externalizable, Comparable
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 String
STRING_DELIMITER
protected String
targetClassName
The name of the class of the target persistable object.
-
Constructor Summary
Constructors Modifier Constructor Description SingleFieldId()
protected
SingleFieldId(Class pcClass)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
assertKeyNotNull(Object key)
Assert that the key is not null.protected int
compare(SingleFieldId o)
Determine the ordering of identity objects.boolean
equals(Object obj)
Check the class and class name and object type.abstract T
getKeyAsObject()
String
getTargetClassName()
int
hashCode()
protected abstract boolean
keyEquals(SingleFieldId other)
void
readExternal(ObjectInput in)
Read from the input stream.void
writeExternal(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 String STRING_DELIMITER
- See Also:
- Constant Field Values
-
targetClassName
protected String targetClassName
The name of the class of the target persistable object.
-
hashCode
protected int hashCode
-
-
Constructor Detail
-
SingleFieldId
protected SingleFieldId(Class pcClass)
-
SingleFieldId
public SingleFieldId()
-
-
Method Detail
-
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()
-
getKeyAsObject
public abstract T getKeyAsObject()
-
equals
public boolean equals(Object obj)
Check the class and class name and object type.
-
keyEquals
protected abstract boolean keyEquals(SingleFieldId other)
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
Write to the output stream.- Specified by:
writeExternal
in interfaceExternalizable
- 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 interfaceExternalizable
- Parameters:
in
- Input object- Throws:
IOException
ClassNotFoundException
-
compare
protected int compare(SingleFieldId 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
-
-