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.commons.dbcp.datasources;
19:
20: import java.io.Serializable;
21:
22: /**
23: * @version $Revision: 479137 $ $Date: 2006-11-25 08:51:48 -0700 (Sat, 25 Nov 2006) $
24: */
25: class PoolKey implements Serializable {
26: private String datasourceName;
27: private String username;
28:
29: PoolKey(String datasourceName, String username) {
30: this .datasourceName = datasourceName;
31: this .username = username;
32: }
33:
34: public boolean equals(Object obj) {
35: if (obj instanceof PoolKey) {
36: PoolKey pk = (PoolKey) obj;
37: return (null == datasourceName ? null == pk.datasourceName
38: : datasourceName.equals(pk.datasourceName))
39: && (null == username ? null == pk.username
40: : username.equals(pk.username));
41: } else {
42: return false;
43: }
44: }
45:
46: public int hashCode() {
47: int h = 0;
48: if (datasourceName != null) {
49: h += datasourceName.hashCode();
50: }
51: if (username != null) {
52: h = 29 * h + username.hashCode();
53: }
54: return h;
55: }
56:
57: public String toString() {
58: StringBuffer sb = new StringBuffer(50);
59: sb.append("PoolKey(");
60: sb.append(username).append(", ").append(datasourceName);
61: sb.append(')');
62: return sb.toString();
63: }
64: }
|