Class ObjectIdentityImpl
- java.lang.Object
-
- org.springframework.security.acls.domain.ObjectIdentityImpl
-
- All Implemented Interfaces:
java.io.Serializable,ObjectIdentity
public class ObjectIdentityImpl extends java.lang.Object implements ObjectIdentity
Simple implementation ofObjectIdentity.Uses
Strings to store the identity of the domain object instance. Also offers a constructor that uses reflection to build the identity information.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor 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 theObjectIdentityImplbased on the passed object instance.ObjectIdentityImpl(java.lang.String type, java.io.Serializable identifier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Important so caching operates properly.java.io.SerializablegetIdentifier()Obtains the actual identifier.java.lang.StringgetType()Obtains the "type" metadata for the domain object.inthashCode()Important so caching operates properly.java.lang.StringtoString()
-
-
-
Constructor Detail
-
ObjectIdentityImpl
public ObjectIdentityImpl(java.lang.String type, java.io.Serializable identifier)
-
ObjectIdentityImpl
public ObjectIdentityImpl(java.lang.Class<?> javaType, java.io.Serializable identifier)Constructor which uses the name of the supplied class as the type property.
-
ObjectIdentityImpl
public ObjectIdentityImpl(java.lang.Object object) throws IdentityUnavailableExceptionCreates theObjectIdentityImplbased on the passed object instance. The passed object must provide agetId()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.- Parameters:
object- the domain object instance to create an identity for.- Throws:
IdentityUnavailableException- if identity could not be extracted
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
Important so caching operates properly.Considers an object of the same class equal if it has the same
classnameandidproperties.Numeric identities (Integer and Long values) are considered equal if they are numerically equal. Other serializable types are evaluated using a simple equality.
- Specified by:
equalsin interfaceObjectIdentity- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- object to compare- Returns:
trueif the presented object matches this object- See Also:
Object.equals(Object)
-
getIdentifier
public java.io.Serializable getIdentifier()
Description copied from interface:ObjectIdentityObtains the actual identifier. This identifier must not be reused to represent other domain objects with the same javaType.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.
- Specified by:
getIdentifierin interfaceObjectIdentity- Returns:
- the identifier (unique within this type; never null)
-
getType
public java.lang.String getType()
Description copied from interface:ObjectIdentityObtains the "type" metadata for the domain object. This will often be a Java type name (an interface or a class) – traditionally it is the name of the domain object implementation class.- Specified by:
getTypein interfaceObjectIdentity- Returns:
- the "type" of the domain object (never null).
-
hashCode
public int hashCode()
Important so caching operates properly.- Specified by:
hashCodein interfaceObjectIdentity- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hash
- See Also:
Object.hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-