forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPair.java
More file actions
40 lines (31 loc) · 795 Bytes
/
Copy pathPair.java
File metadata and controls
40 lines (31 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package modern.challenge;
public final class Pair<L, R> extends Tuple implements Comparable {
final L left;
final R right;
public Pair(L left, R right) {
this.left = left;
this.right = right;
}
public class Entry<L, R> {
}
static <L, R> Pair<L, R> of(L left, R right) {
return new Pair<>(left, right);
}
@Override
public int hashCode() {
return left.hashCode() ^ right.hashCode();
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Pair)) {
return false;
}
Pair obj = (Pair) o;
return this.left.equals(obj.left)
&& this.right.equals(obj.right);
}
@Override
public int compareTo(Object o) {
return 0;
}
}