1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * 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 and15 * limitations under the License.16 */1718packageorg.apache.jetspeed.capabilities.impl;
1920import org.apache.jetspeed.capabilities.Capability;
2122/***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 */2829publicclassCapabilityImpl implements Capability
30 {
31privateint capabilityId;
32private String name;
3334/* (non-Javadoc)35 * @see org.apache.jetspeed.om.registry.Capability#setCapabilityId(int)36 */37publicvoid setCapabilityId(int id)
38 {
39this.capabilityId = id;
40 }
4142/* (non-Javadoc)43 * @see org.apache.jetspeed.om.registry.Capability#getCapabilityId()44 */45publicint getCapabilityId()
46 {
47returnthis.capabilityId;
48 }
4950/* (non-Javadoc)51 * @see org.apache.jetspeed.om.registry.Capability#setName(java.lang.String)52 */53publicvoid setName(String name)
54 {
55this.name = name;
56 }
5758/* (non-Javadoc)59 * @see org.apache.jetspeed.om.registry.Capability#getName()60 */61public String getName()
62 {
63returnthis.name;
64 }
656667/***68 * Implements the hashCode calculation so two different objects with the content return the same hashcode....69 */70publicint hashCode()
71 {
72return name.hashCode();
73 }
7475/***76 * Implements the equals operation so that 2 elements are equal if77 * all their member values are equal.78 *79 * 80 * @param object to compare this one with81 * @return true if both objects represent the same (logical) content82 */83publicboolean equals(Object object)
84 {
85if (!(object instanceof Capability))
86 {
87return false;
88 }
89if (this == object)
90returntrue;
91// Don't check the ID - id is only set through OJB so this would not recognize equality correctly 92/* if (this.capabilityId != ((Capability)object).getCapabilityId())93 return false;94 */95 String oName = ((Capability)object).getName();
96if (
97 (oName == null) && (name == null)
98 ||
99 (oName == name)
100 ||
101 ((oName != null) && (oName.equals(name)))
102 )
103returntrue;
104return false;
105 }
106107 }