| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
| ObjectIdentity |
|
| 1.0;1 |
| 1 | /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited |
|
| 2 | * |
|
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 4 | * you may not use this file except in compliance with the License. |
|
| 5 | * You may obtain a copy of the License at |
|
| 6 | * |
|
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 8 | * |
|
| 9 | * 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 | /** |
|
| 21 | * Interface representing the identity of an individual domain object instance. |
|
| 22 | * |
|
| 23 | * <P> |
|
| 24 | * As implementations are used as the key for caching and lookup, it is |
|
| 25 | * essential that implementations provide methods so that object-equality |
|
| 26 | * rather than reference-equality can be relied upon by caches. In other |
|
| 27 | * words, a cache can consider two <code>ObjectIdentity</code>s equal if |
|
| 28 | * <code>identity1.equals(identity2)</code>, rather than reference-equality of |
|
| 29 | * <code>identity1==identity2</code>. |
|
| 30 | * </p> |
|
| 31 | * |
|
| 32 | * @author Ben Alex |
|
| 33 | * @version $Id: ObjectIdentity.java 1784 2007-02-24 21:00:24Z luke_t $ |
|
| 34 | */ |
|
| 35 | public interface ObjectIdentity extends Serializable { |
|
| 36 | //~ Methods ======================================================================================================== |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Refer to the <code>java.lang.Object</code> documentation for the interface contract. |
|
| 40 | * |
|
| 41 | * @param obj to be compared |
|
| 42 | * |
|
| 43 | * @return <code>true</code> if the objects are equal, <code>false</code> otherwise |
|
| 44 | */ |
|
| 45 | boolean equals(Object obj); |
|
| 46 | ||
| 47 | /** |
|
| 48 | * Obtains the actual identifier. This identifier must not be reused to represent other domain objects with |
|
| 49 | * the same <code>javaType</code>.<p>Because ACLs are largely immutable, it is strongly recommended to use |
|
| 50 | * a synthetic identifier (such as a database sequence number for the primary key). Do not use an identifier with |
|
| 51 | * business meaning, as that business meaning may change.</p> |
|
| 52 | * |
|
| 53 | * @return the identifier (unique within this <code>javaType</code> |
|
| 54 | */ |
|
| 55 | Serializable getIdentifier(); |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Obtains the Java type represented by the domain object. |
|
| 59 | * |
|
| 60 | * @return the Java type of the domain object |
|
| 61 | */ |
|
| 62 | Class getJavaType(); |
|
| 63 | ||
| 64 | /** |
|
| 65 | * Refer to the <code>java.lang.Object</code> documentation for the interface contract. |
|
| 66 | * |
|
| 67 | * @return a hash code representation of this object |
|
| 68 | */ |
|
| 69 | int hashCode(); |
|
| 70 | } |