forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPair.java
More file actions
32 lines (25 loc) · 742 Bytes
/
Copy pathPair.java
File metadata and controls
32 lines (25 loc) · 742 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
package modern.challenge;
public final class Pair<V, C> {
final V character;
final C occurrences;
public Pair(V character, C occurrences) {
this.character = character;
this.occurrences = occurrences;
}
static <V, C> Pair<V, C> of(V character, C occurrences) {
return new Pair<>(character, occurrences);
}
@Override
public int hashCode() {
return character.hashCode() ^ character.hashCode();
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Pair)) {
return false;
}
Pair obj = (Pair) o;
return this.character.equals(obj.character)
&& this.occurrences.equals(obj.occurrences);
}
}