This repository was archived by the owner on Jan 5, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
src/main/java/com/scorpiac/javarant Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,4 +17,14 @@ static Comment fromJson(JsonObject json) {
1717 Image .fromJson (json .get ("attached_image" ))
1818 );
1919 }
20+
21+ @ Override
22+ public boolean equals (Object obj ) {
23+ return obj instanceof Comment && ((Comment ) obj ).getId () == getId ();
24+ }
25+
26+ @ Override
27+ public int hashCode () {
28+ return getId ();
29+ }
2030}
Original file line number Diff line number Diff line change @@ -28,6 +28,16 @@ static Image fromJson(JsonElement json) {
2828 return new Image (obj .get ("url" ).getAsString (), obj .get ("width" ).getAsInt (), obj .get ("height" ).getAsInt ());
2929 }
3030
31+ @ Override
32+ public boolean equals (Object obj ) {
33+ return obj instanceof Image && ((Image ) obj ).getUrl ().equals (url );
34+ }
35+
36+ @ Override
37+ public int hashCode () {
38+ return url .hashCode ();
39+ }
40+
3141 /**
3242 * Get the image url.
3343 *
Original file line number Diff line number Diff line change @@ -111,6 +111,16 @@ public String link() {
111111 return DevRant .link (DevRant .RANT_URL + "/" + getId ());
112112 }
113113
114+ @ Override
115+ public boolean equals (Object obj ) {
116+ return obj instanceof Rant && ((Rant ) obj ).getId () == getId ();
117+ }
118+
119+ @ Override
120+ public int hashCode () {
121+ return getId ();
122+ }
123+
114124 /**
115125 * Get the tags from this rant.
116126 */
Original file line number Diff line number Diff line change @@ -176,6 +176,16 @@ public String avatarLink() {
176176 return DevRant .AVATARS_URL + "/" + avatar ;
177177 }
178178
179+ @ Override
180+ public boolean equals (Object obj ) {
181+ return obj instanceof User && ((User ) obj ).getId () == id ;
182+ }
183+
184+ @ Override
185+ public int hashCode () {
186+ return id ;
187+ }
188+
179189 /**
180190 * Get the user id.
181191 */
You can’t perform that action at this time.
0 commit comments