Skip to content

Commit ef1429b

Browse files
committed
Implement ProxyPartitionKey equals and hashcode, close AsyncHttpClient#1079
1 parent 2c3e12a commit ef1429b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/main/java/com/ning/http/client/ConnectionPoolPartitioning.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,37 @@ public ProxyPartitionKey(String proxyUrl, String targetHostBaseUrl) {
2626
this.targetHostBaseUrl = targetHostBaseUrl;
2727
}
2828

29+
@Override
30+
public int hashCode() {
31+
final int prime = 31;
32+
int result = 1;
33+
result = prime * result + ((proxyUrl == null) ? 0 : proxyUrl.hashCode());
34+
result = prime * result + ((targetHostBaseUrl == null) ? 0 : targetHostBaseUrl.hashCode());
35+
return result;
36+
}
37+
38+
@Override
39+
public boolean equals(Object obj) {
40+
if (this == obj)
41+
return true;
42+
if (obj == null)
43+
return false;
44+
if (!(obj instanceof ProxyPartitionKey))
45+
return false;
46+
ProxyPartitionKey other = (ProxyPartitionKey) obj;
47+
if (proxyUrl == null) {
48+
if (other.proxyUrl != null)
49+
return false;
50+
} else if (!proxyUrl.equals(other.proxyUrl))
51+
return false;
52+
if (targetHostBaseUrl == null) {
53+
if (other.targetHostBaseUrl != null)
54+
return false;
55+
} else if (!targetHostBaseUrl.equals(other.targetHostBaseUrl))
56+
return false;
57+
return true;
58+
}
59+
2960
@Override
3061
public String toString() {
3162
return new StringBuilder()//

0 commit comments

Comments
 (0)