Store the originating Sone in the post.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Post.java
index 8c7ac51..456b205 100644 (file)
@@ -25,6 +25,9 @@ package net.pterodactylus.sone.data;
  */
 public class Post {
 
+       /** The Sone this post belongs to. */
+       private final Sone sone;
+
        /** The time of the post (in milliseconds since Jan 1, 1970 UTC). */
        private final long time;
 
@@ -34,22 +37,34 @@ public class Post {
        /**
         * Creates a new post.
         *
+        * @param sone
+        *            The Sone this post belongs to
         * @param time
         *            The time of the post (in milliseconds since Jan 1, 1970 UTC)
         * @param text
         *            The text of the post
         */
-       public Post(long time, String text) {
+       public Post(Sone sone, long time, String text) {
+               this.sone = sone;
                this.time = time;
                this.text = text;
        }
 
        /**
+        * Returns the Sone this post belongs to.
+        *
+        * @return The Sone of this post
+        */
+       public Sone getSone() {
+               return sone;
+       }
+
+       /**
         * Returns the time of the post.
         *
         * @return The time of the post (in milliseconds since Jan 1, 1970 UTC)
         */
-       public long time() {
+       public long getTime() {
                return time;
        }
 
@@ -58,8 +73,32 @@ public class Post {
         *
         * @return The text of the post
         */
-       public String text() {
+       public String getText() {
                return text;
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int hashCode() {
+               return text.hashCode() ^ (int) (time >> 32) ^ (int) (time & 0xffffffff);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof Post)) {
+                       return false;
+               }
+               Post post = (Post) object;
+               return (post.time == time) && (post.text.equals(text));
+       }
+
 }