01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15: package org.acegisecurity.acls.objectidentity;
16:
17: import java.io.Serializable;
18:
19: /**
20: * Interface representing the identity of an individual domain object instance.
21: *
22: * <P>
23: * As implementations are used as the key for caching and lookup, it is
24: * essential that implementations provide methods so that object-equality
25: * rather than reference-equality can be relied upon by caches. In other
26: * words, a cache can consider two <code>ObjectIdentity</code>s equal if
27: * <code>identity1.equals(identity2)</code>, rather than reference-equality of
28: * <code>identity1==identity2</code>.
29: * </p>
30: *
31: * @author Ben Alex
32: * @version $Id: ObjectIdentity.java 1784 2007-02-24 21:00:24Z luke_t $
33: */
34: public interface ObjectIdentity extends Serializable {
35: //~ Methods ========================================================================================================
36:
37: /**
38: * Refer to the <code>java.lang.Object</code> documentation for the interface contract.
39: *
40: * @param obj to be compared
41: *
42: * @return <code>true</code> if the objects are equal, <code>false</code> otherwise
43: */
44: boolean equals(Object obj);
45:
46: /**
47: * Obtains the actual identifier. This identifier must not be reused to represent other domain objects with
48: * the same <code>javaType</code>.<p>Because ACLs are largely immutable, it is strongly recommended to use
49: * a synthetic identifier (such as a database sequence number for the primary key). Do not use an identifier with
50: * business meaning, as that business meaning may change.</p>
51: *
52: * @return the identifier (unique within this <code>javaType</code>
53: */
54: Serializable getIdentifier();
55:
56: /**
57: * Obtains the Java type represented by the domain object.
58: *
59: * @return the Java type of the domain object
60: */
61: Class getJavaType();
62:
63: /**
64: * Refer to the <code>java.lang.Object</code> documentation for the interface contract.
65: *
66: * @return a hash code representation of this object
67: */
68: int hashCode();
69: }
|