Merge branch 'partial-rewrite' into less-critical
[Sone.git] / src / main / java / net / pterodactylus / sone / text / SoneTextParser.java
index 9aacff6..f2ca0c5 100644 (file)
@@ -32,6 +32,9 @@ import net.pterodactylus.sone.database.PostProvider;
 import net.pterodactylus.sone.database.SoneProvider;
 import net.pterodactylus.util.io.Closer;
 import net.pterodactylus.util.logging.Logging;
+
+import com.google.common.base.Optional;
+
 import freenet.keys.FreenetURI;
 
 /**
@@ -258,9 +261,9 @@ public class SoneTextParser implements Parser<SoneTextParserContext> {
                                        if (linkType == LinkType.POST) {
                                                if (line.length() >= (7 + 36)) {
                                                        String postId = line.substring(7, 43);
-                                                       Post post = postProvider.getPost(postId);
-                                                       if ((post != null) && (post.getSone() != null)) {
-                                                               parts.add(new PostPart(post));
+                                                       Optional<Post> post = postProvider.getPost(postId);
+                                                       if (post.isPresent()) {
+                                                               parts.add(new PostPart(post.get()));
                                                        } else {
                                                                parts.add(new PlainTextPart(line.substring(0, 43)));
                                                        }