|
@@ -38,23 +38,33 @@ public class User {
|
38
|
38
|
this.name = name;
|
39
|
39
|
}
|
40
|
40
|
|
41
|
|
- public boolean equals(User otherUser) {
|
42
|
|
-
|
43
|
|
- try {
|
44
|
|
- if (this.getName().equalsIgnoreCase(otherUser.getName()) && this.getId() == otherUser.getId()) {
|
45
|
|
- return true;
|
46
|
|
- }
|
47
|
|
- } catch (NullPointerException e) {
|
48
|
|
-
|
49
|
|
- if (this.getName() == null && otherUser.getName() == null) {
|
50
|
|
- return true;
|
51
|
|
- } else {
|
52
|
|
- return false;
|
53
|
|
- }
|
54
|
|
- }
|
55
|
|
- return false;
|
|
41
|
+ @Override
|
|
42
|
+ public boolean equals(Object o) {
|
|
43
|
+ if (this == o) return true;
|
|
44
|
+ if (o == null || getClass() != o.getClass()) return false;
|
|
45
|
+ User user = (User) o;
|
|
46
|
+ return id == user.id &&
|
|
47
|
+ Objects.equals(name, user.name);
|
56
|
48
|
}
|
57
|
49
|
|
|
50
|
+ // @Override
|
|
51
|
+// public boolean equals(Object otherUser) {
|
|
52
|
+//
|
|
53
|
+// try {
|
|
54
|
+// if (this.getName().equalsIgnoreCase(otherUser.getName()) && this.getId() == otherUser.getId()) {
|
|
55
|
+// return true;
|
|
56
|
+// }
|
|
57
|
+// } catch (NullPointerException e) {
|
|
58
|
+//
|
|
59
|
+// if (this.getName() == null && otherUser.getName() == null) {
|
|
60
|
+// return true;
|
|
61
|
+// } else {
|
|
62
|
+// return false;
|
|
63
|
+// }
|
|
64
|
+// }
|
|
65
|
+// return false;
|
|
66
|
+// }
|
|
67
|
+
|
58
|
68
|
@Override
|
59
|
69
|
public int hashCode() {
|
60
|
70
|
return Objects.hash(id, name);
|