🔥 Remove setKnown() method from replies
[Sone.git] / src / main / java / net / pterodactylus / sone / database / memory / MemoryPostReply.java
index a48b017..5764622 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - MemoryPostReply.java - Copyright Â© 2013–2015 David Roden
+ * Sone - MemoryPostReply.java - Copyright Â© 2013–2020 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,6 +17,8 @@
 
 package net.pterodactylus.sone.database.memory;
 
+import static com.google.common.base.Optional.fromNullable;
+
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.PostReply;
 import net.pterodactylus.sone.data.Sone;
@@ -26,8 +28,6 @@ import com.google.common.base.Optional;
 
 /**
  * Memory-based {@link PostReply} implementation.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David â€˜Bombe’ Roden</a>
  */
 class MemoryPostReply implements PostReply {
 
@@ -97,7 +97,7 @@ class MemoryPostReply implements PostReply {
         */
        @Override
        public Sone getSone() {
-               return soneProvider.getSone(soneId).get();
+               return soneProvider.getSone(soneId);
        }
 
        /**
@@ -124,15 +124,6 @@ class MemoryPostReply implements PostReply {
                return database.isPostReplyKnown(this);
        }
 
-       /**
-        * {@inheritDocs}
-        */
-       @Override
-       public PostReply setKnown(boolean known) {
-               database.setPostReplyKnown(this, known);
-               return this;
-       }
-
        //
        // POSTREPLY METHODS
        //
@@ -150,7 +141,7 @@ class MemoryPostReply implements PostReply {
         */
        @Override
        public Optional<Post> getPost() {
-               return database.getPost(postId);
+               return fromNullable(database.getPost(postId));
        }
 
        //
@@ -177,4 +168,17 @@ class MemoryPostReply implements PostReply {
                return memoryPostReply.id.equals(id);
        }
 
+       @Override
+       public String toString() {
+               return "MemoryPostReply{" +
+                               "database=" + database +
+                               ", soneProvider=" + soneProvider +
+                               ", id='" + id + '\'' +
+                               ", soneId='" + soneId + '\'' +
+                               ", time=" + time +
+                               ", text='" + text + '\'' +
+                               ", postId='" + postId + '\'' +
+                               '}';
+       }
+
 }