Use all available parameters for post equality.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Post.java
index a42cfaa..58c50e1 100644 (file)
@@ -17,7 +17,6 @@
 
 package net.pterodactylus.sone.data;
 
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -136,7 +135,7 @@ public class Post {
         *
         * @return All replies to this post
         */
-       public Collection<Reply> getReplies() {
+       public Set<Reply> getReplies() {
                return Collections.unmodifiableSet(replies);
        }
 
@@ -174,7 +173,7 @@ public class Post {
         */
        @Override
        public int hashCode() {
-               return id.hashCode();
+               return id.hashCode() ^ sone.hashCode() ^ (int) (time >>> 32) ^ (int) (time & 0xffffffff) ^ text.hashCode();
        }
 
        /**
@@ -185,7 +184,8 @@ public class Post {
                if (!(object instanceof Post)) {
                        return false;
                }
-               return ((Post) object).id.equals(id);
+               Post post = (Post) object;
+               return post.id.equals(id) && post.sone.equals(sone) && (post.time == time) && post.text.equals(text);
        }
 
 }