KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > domain > StoreKey


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.domain;
18
19 import java.io.Serializable JavaDoc;
20
21 import org.alfresco.util.EqualsHelper;
22
23 /**
24  * Compound key for persistence of {@link org.alfresco.repo.domain.Store}
25  *
26  * @author Derek Hulley
27  */

28 public class StoreKey implements Serializable JavaDoc
29 {
30     private static final long serialVersionUID = 3618140052220096569L;
31
32     private String JavaDoc protocol;
33     private String JavaDoc identifier;
34     
35     public StoreKey()
36     {
37     }
38     
39     public StoreKey(String JavaDoc protocol, String JavaDoc identifier)
40     {
41         setProtocol(protocol);
42         setIdentifier(identifier);
43     }
44     
45     public String JavaDoc toString()
46     {
47         return ("StoreKey[" +
48                 " protocol=" + protocol +
49                 ", identifier=" + identifier +
50                 "]");
51     }
52     
53     public int hashCode()
54     {
55         return (this.protocol.hashCode() + this.identifier.hashCode());
56     }
57     
58     public boolean equals(Object JavaDoc obj)
59     {
60         if (this == obj)
61         {
62             return true;
63         }
64         else if (!(obj instanceof StoreKey))
65         {
66             return false;
67         }
68         StoreKey that = (StoreKey) obj;
69         return (EqualsHelper.nullSafeEquals(this.protocol, that.protocol) &&
70                 EqualsHelper.nullSafeEquals(this.identifier, that.identifier));
71     }
72     
73     public String JavaDoc getProtocol()
74     {
75         return protocol;
76     }
77     
78     /**
79      * Tamper-proof method only to be used by introspectors
80      */

81     private void setProtocol(String JavaDoc protocol)
82     {
83         this.protocol = protocol;
84     }
85
86     public String JavaDoc getIdentifier()
87     {
88         return identifier;
89     }
90     
91     /**
92      * Tamper-proof method only to be used by introspectors
93      */

94     private void setIdentifier(String JavaDoc identifier)
95     {
96         this.identifier = identifier;
97     }
98 }
99
Popular Tags