KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > security > permissions > impl > AbstractPermissionEntry


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.security.permissions.impl;
18
19 import org.alfresco.repo.security.permissions.PermissionEntry;
20 import org.alfresco.util.EqualsHelper;
21
22 /**
23  * This class provides common support for hash code and equality.
24  *
25  * @author andyh
26  */

27 public abstract class AbstractPermissionEntry implements PermissionEntry
28 {
29
30     public AbstractPermissionEntry()
31     {
32         super();
33     }
34
35     @Override JavaDoc
36     public boolean equals(Object JavaDoc o)
37     {
38         if (this == o)
39         {
40             return true;
41         }
42         if (!(o instanceof AbstractPermissionEntry))
43         {
44             return false;
45         }
46         AbstractPermissionEntry other = (AbstractPermissionEntry) o;
47         return EqualsHelper.nullSafeEquals(this.getNodeRef(),
48                 other.getNodeRef())
49                 && EqualsHelper.nullSafeEquals(this.getPermissionReference(),
50                         other.getPermissionReference())
51                 && EqualsHelper.nullSafeEquals(this.getAuthority(), other.getAuthority())
52                 && EqualsHelper.nullSafeEquals(this.getAccessStatus(), other.getAccessStatus());
53     }
54
55     @Override JavaDoc
56     public int hashCode()
57     {
58         int hashCode = getNodeRef().hashCode();
59         if (getPermissionReference() != null)
60         {
61             hashCode = hashCode * 37 + getPermissionReference().hashCode();
62         }
63         if (getAuthority() != null)
64         {
65             hashCode = hashCode * 37 + getAuthority().hashCode();
66         }
67         if(getAccessStatus() != null)
68         {
69            hashCode = hashCode * 37 + getAccessStatus().hashCode();
70         }
71         return hashCode;
72     }
73
74     
75
76 }
77
Popular Tags