public class ObjectIdentityImpl extends java.lang.Object implements ObjectIdentity
ObjectIdentity
.
Uses String
s to store the identity of the domain object instance. Also
offers a constructor that uses reflection to build the identity information.
Constructor and Description |
---|
ObjectIdentityImpl(java.lang.Class<?> javaType,
java.io.Serializable identifier)
Constructor which uses the name of the supplied class as the type
property.
|
ObjectIdentityImpl(java.lang.Object object)
Creates the
ObjectIdentityImpl based on the passed object instance. |
ObjectIdentityImpl(java.lang.String type,
java.io.Serializable identifier) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Important so caching operates properly.
|
java.io.Serializable |
getIdentifier()
Obtains the actual identifier.
|
java.lang.String |
getType()
Obtains the "type" metadata for the domain object.
|
int |
hashCode()
Important so caching operates properly.
|
java.lang.String |
toString() |
public ObjectIdentityImpl(java.lang.String type, java.io.Serializable identifier)
public ObjectIdentityImpl(java.lang.Class<?> javaType, java.io.Serializable identifier)
public ObjectIdentityImpl(java.lang.Object object) throws IdentityUnavailableException
ObjectIdentityImpl
based on the passed object instance.
The passed object must provide a getId()
method, otherwise an
exception will be thrown.
The class name of the object passed will be considered the type
, so if
more control is required, a different constructor should be used.
object
- the domain object instance to create an identity for.IdentityUnavailableException
- if identity could not be extractedpublic boolean equals(java.lang.Object obj)
Considers an object of the same class equal if it has the same
classname
and id
properties.
Numeric identities (Integer and Long values) are considered equal if they are numerically equal. Other serializable types are evaluated using a simple equality.
equals
in interface ObjectIdentity
equals
in class java.lang.Object
obj
- object to comparetrue
if the presented object matches this objectObject.equals(Object)
public java.io.Serializable getIdentifier()
ObjectIdentity
Because ACLs are largely immutable, it is strongly recommended to use a synthetic identifier (such as a database sequence number for the primary key). Do not use an identifier with business meaning, as that business meaning may change in the future such change will cascade to the ACL subsystem data.
getIdentifier
in interface ObjectIdentity
public java.lang.String getType()
ObjectIdentity
getType
in interface ObjectIdentity
public int hashCode()
hashCode
in interface ObjectIdentity
hashCode
in class java.lang.Object
Object.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object