Package org.datanucleus.identity
Class SingleFieldId<T>
- 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 inthashCodeprotected static StringSTRING_DELIMITERprotected StringtargetClassNameThe name of the class of the target persistable object.
-
Constructor Summary
Constructors Modifier Constructor Description SingleFieldId()protectedSingleFieldId(Class pcClass)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidassertKeyNotNull(Object key)Assert that the key is not null.protected intcompare(SingleFieldId o)Determine the ordering of identity objects.booleanequals(Object obj)Check the class and class name and object type.abstract TgetKeyAsObject()StringgetTargetClassName()inthashCode()protected abstract booleankeyEquals(SingleFieldId other)voidreadExternal(ObjectInput in)Read from the input stream.voidwriteExternal(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:
writeExternalin 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:
readExternalin interfaceExternalizable- Parameters:
in- Input object- Throws:
IOExceptionClassNotFoundException
-
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
-
-