Override equals() and hashCode().
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 8 Nov 2013 19:13:03 +0000 (20:13 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:55 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/text/PostPart.java

index 1e7eda1..f33055b 100644 (file)
@@ -17,6 +17,8 @@
 
 package net.pterodactylus.sone.text;
 
+import static com.google.common.base.Objects.equal;
+
 import net.pterodactylus.sone.data.Post;
 
 /**
@@ -61,4 +63,18 @@ public class PostPart implements Part {
                return post.getText();
        }
 
+       @Override
+       public int hashCode() {
+               return getPost().hashCode();
+       }
+
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof PostPart)) {
+                       return false;
+               }
+               PostPart postPart = (PostPart) object;
+               return equal(getPost(), postPart.getPost());
+       }
+
 }