01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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: private int capabilityId;
31: private String name;
32:
33: /* (non-Javadoc)
34: * @see org.apache.jetspeed.om.registry.Capability#setCapabilityId(int)
35: */
36: public void setCapabilityId(int id) {
37: this .capabilityId = id;
38: }
39:
40: /* (non-Javadoc)
41: * @see org.apache.jetspeed.om.registry.Capability#getCapabilityId()
42: */
43: public int getCapabilityId() {
44: return this .capabilityId;
45: }
46:
47: /* (non-Javadoc)
48: * @see org.apache.jetspeed.om.registry.Capability#setName(java.lang.String)
49: */
50: public void setName(String name) {
51: this .name = name;
52: }
53:
54: /* (non-Javadoc)
55: * @see org.apache.jetspeed.om.registry.Capability#getName()
56: */
57: public String getName() {
58: return this .name;
59: }
60:
61: /**
62: * Implements the hashCode calculation so two different objects with the content return the same hashcode....
63: */
64: public int hashCode() {
65: return name.hashCode();
66: }
67:
68: /**
69: * Implements the equals operation so that 2 elements are equal if
70: * all their member values are equal.
71: *
72: *
73: * @param object to compare this one with
74: * @return true if both objects represent the same (logical) content
75: */
76: public boolean equals(Object object) {
77: if (!(object instanceof Capability)) {
78: return false;
79: }
80: if (this == object)
81: return true;
82: // Don't check the ID - id is only set through OJB so this would not recognize equality correctly
83: /* if (this.capabilityId != ((Capability)object).getCapabilityId())
84: return false;
85: */
86: String oName = ((Capability) object).getName();
87: if ((oName == null) && (name == null) || (oName == name)
88: || ((oName != null) && (oName.equals(name))))
89: return true;
90: return false;
91: }
92:
93: }
|