org.apache.openjpa.util
Class OpenJPAId

java.lang.Object
  extended by org.apache.openjpa.util.OpenJPAId
All Implemented Interfaces:
Serializable, Comparable
Direct Known Subclasses:
BigDecimalId, BigIntegerId, ByteId, CharId, DateId, DoubleId, FloatId, Id, IntId, LongId, ObjectId, ShortId, StringId

public abstract class OpenJPAId
extends Object
implements Comparable, Serializable

Identity class extended by builtin OpenJPA identity objects.

Author:
Steve Kim
See Also:
Serialized Form

Field Summary
protected  boolean subs
           
protected  Class type
           
 
Constructor Summary
protected OpenJPAId()
           
protected OpenJPAId(Class type)
           
protected OpenJPAId(Class type, boolean subs)
           
 
Method Summary
 int compareTo(Object other)
           
 boolean equals(Object o)
           
abstract  Object getIdObject()
          Return the identity value as an object.
 Class getType()
          Return the persistent class which this id instance represents.
 int hashCode()
          Generate the hashcode for this Id.
 boolean hasSubclasses()
          Whether this oid might be for a subclass of the given type.
protected abstract  boolean idEquals(OpenJPAId other)
          Compare the id to the id of the given instance.
protected abstract  int idHash()
          Return the id's hash code.
 void setManagedInstanceType(Class type)
          Set the exact type of the described instance once it is known.
 void setManagedInstanceType(Class type, boolean subs)
          Set the exact type of the described instance once it is known.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected Class type

subs

protected boolean subs
Constructor Detail

OpenJPAId

protected OpenJPAId()

OpenJPAId

protected OpenJPAId(Class type)

OpenJPAId

protected OpenJPAId(Class type,
                    boolean subs)
Method Detail

getType

public Class getType()
Return the persistent class which this id instance represents.


hasSubclasses

public boolean hasSubclasses()
Whether this oid might be for a subclass of the given type. Defaults to true.


setManagedInstanceType

public void setManagedInstanceType(Class type)
Set the exact type of the described instance once it is known.


setManagedInstanceType

public void setManagedInstanceType(Class type,
                                   boolean subs)
Set the exact type of the described instance once it is known.


getIdObject

public abstract Object getIdObject()
Return the identity value as an object.


idHash

protected abstract int idHash()
Return the id's hash code.


idEquals

protected abstract boolean idEquals(OpenJPAId other)
Compare the id to the id of the given instance.


hashCode

public int hashCode()
Generate the hashcode for this Id. Cache the type's generated hashcode so that it doesn't have to be generated each time.

Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Object other)
Specified by:
compareTo in interface Comparable


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.