File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
cqrs/src/main/java/com/iluwatar/cqrs/dto Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .iluwatar .cqrs .dto ;
2
2
3
+ import java .util .Objects ;
4
+
3
5
/**
4
6
*
5
7
* This is a DTO (Data Transfer Object) author, contains only useful information to be returned
@@ -48,4 +50,22 @@ public String toString() {
48
50
return "AuthorDTO [name=" + name + ", email=" + email + ", username=" + username + "]" ;
49
51
}
50
52
53
+ @ Override
54
+ public int hashCode () {
55
+ return Objects .hash (username , name , email );
56
+ }
57
+
58
+ @ Override
59
+ public boolean equals (Object obj ) {
60
+ if (this == obj ) {
61
+ return true ;
62
+ }
63
+ if (!(obj instanceof Author )) {
64
+ return false ;
65
+ }
66
+ Author other = (Author ) obj ;
67
+ return username .equals (other .getUsername ()) && email .equals (other .getEmail ()) && name .equals (other .getName ());
68
+
69
+ }
70
+
51
71
}
Original file line number Diff line number Diff line change 1
1
package com .iluwatar .cqrs .dto ;
2
2
3
+ import java .util .Objects ;
4
+
3
5
/**
4
6
*
5
7
* This is a DTO (Data Transfer Object) book, contains only useful information to be returned
@@ -40,4 +42,21 @@ public String toString() {
40
42
return "BookDTO [title=" + title + ", price=" + price + "]" ;
41
43
}
42
44
45
+ @ Override
46
+ public int hashCode () {
47
+ return Objects .hash (title , price );
48
+ }
49
+
50
+ @ Override
51
+ public boolean equals (Object obj ) {
52
+ if (this == obj ) {
53
+ return true ;
54
+ }
55
+ if (!(obj instanceof Book )) {
56
+ return false ;
57
+ }
58
+ Book book = (Book ) obj ;
59
+ return title .equals (book .getTitle ()) && price == book .getPrice ();
60
+ }
61
+
43
62
}
You can’t perform that action at this time.
0 commit comments