Skip to content

Commit 84b0a3a

Browse files
committed
Add equals and hashCode to picture for easier comparison.
1 parent 14bf9c8 commit 84b0a3a

File tree

1 file changed

+11
-0
lines changed
  • API/src/main/java/io/github/jwdeveloper/tiktok/data/models

1 file changed

+11
-0
lines changed

API/src/main/java/io/github/jwdeveloper/tiktok/data/models/Picture.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.awt.image.BufferedImage;
3131
import java.io.*;
3232
import java.net.URL;
33+
import java.util.Objects;
3334
import java.util.concurrent.CompletableFuture;
3435

3536
public class Picture {
@@ -107,4 +108,14 @@ public Picture asUnsigned() {
107108
public String toString() {
108109
return "Picture{link='" + link + "', image=" + image + "}";
109110
}
111+
112+
@Override
113+
public final boolean equals(Object o) {
114+
return o == this || o instanceof Picture picture && picture.link != null && picture.link.equals(link);
115+
}
116+
117+
@Override
118+
public int hashCode() {
119+
return Objects.hashCode(link);
120+
}
110121
}

0 commit comments

Comments
 (0)