1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.capabilities.impl;
19
20 import org.apache.jetspeed.capabilities.Capability;
21
22 /***
23 * Capability implementation class.
24 *
25 * @author <a href="mailto:roger.ruttimann@earthlink.net">Roger Ruttimann</a>
26 * @version $Id: CapabilityImpl.java 517719 2007-03-13 15:05:48Z ate $
27 */
28
29 public class CapabilityImpl implements Capability
30 {
31 private int capabilityId;
32 private String name;
33
34
35
36
37 public void setCapabilityId(int id)
38 {
39 this.capabilityId = id;
40 }
41
42
43
44
45 public int getCapabilityId()
46 {
47 return this.capabilityId;
48 }
49
50
51
52
53 public void setName(String name)
54 {
55 this.name = name;
56 }
57
58
59
60
61 public String getName()
62 {
63 return this.name;
64 }
65
66
67 /***
68 * Implements the hashCode calculation so two different objects with the content return the same hashcode....
69 */
70 public int hashCode()
71 {
72 return name.hashCode();
73 }
74
75 /***
76 * Implements the equals operation so that 2 elements are equal if
77 * all their member values are equal.
78 *
79 *
80 * @param object to compare this one with
81 * @return true if both objects represent the same (logical) content
82 */
83 public boolean equals(Object object)
84 {
85 if (!(object instanceof Capability))
86 {
87 return false;
88 }
89 if (this == object)
90 return true;
91
92
93
94
95 String oName = ((Capability)object).getName();
96 if (
97 (oName == null) && (name == null)
98 ||
99 (oName == name)
100 ||
101 ((oName != null) && (oName.equals(name)))
102 )
103 return true;
104 return false;
105 }
106
107 }