forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.java
More file actions
48 lines (41 loc) · 952 Bytes
/
B.java
File metadata and controls
48 lines (41 loc) · 952 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
41
42
43
44
45
46
47
48
package modern.challenge;
import java.util.Objects;
public class B {
private final A a;
private final int b;
public B(A a, int b) {
this.a = a;
this.b = b;
}
@Override
public int hashCode() {
int hash = 3;
hash = 47 * hash + Objects.hashCode(this.a);
hash = 47 * hash + this.b;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final B other = (B) obj;
if (this.b != other.b) {
return false;
}
if (!Objects.equals(this.a, other.a)) {
return false;
}
return true;
}
@Override
public String toString() {
return "B{" + "a=" + a + ", b=" + b + '}';
}
}