1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.dbcp2.datasources;
18
19 import java.io.Serializable;
20 import java.util.Objects;
21
22
23
24
25 final class PoolKey implements Serializable {
26 private static final long serialVersionUID = 2252771047542484533L;
27
28 private final String dataSourceName;
29 private final String userName;
30
31 PoolKey(final String dataSourceName, final String userName) {
32 this.dataSourceName = dataSourceName;
33 this.userName = userName;
34 }
35
36 @Override
37 public boolean equals(final Object obj) {
38 if (this == obj) {
39 return true;
40 }
41 if (obj == null) {
42 return false;
43 }
44 if (getClass() != obj.getClass()) {
45 return false;
46 }
47 final PoolKey other = (PoolKey) obj;
48 if (!Objects.equals(dataSourceName, other.dataSourceName)) {
49 return false;
50 }
51 return Objects.equals(userName, other.userName);
52 }
53
54 @Override
55 public int hashCode() {
56 return Objects.hash(dataSourceName, userName);
57 }
58
59 @Override
60 public String toString() {
61 final StringBuilder sb = new StringBuilder(50);
62 sb.append("PoolKey(");
63 sb.append(dataSourceName);
64 sb.append(')');
65 return sb.toString();
66 }
67 }