Simplify some boolean expressions.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / SearchPage.java
index 320e7cd..45773ca 100644 (file)
@@ -131,7 +131,7 @@ public class SearchPage extends SoneTemplatePage {
                        redirectIfNotNull(getImageId(phrase), "imageBrowser.html?image=");
                }
 
-               Set<Sone> sones = webInterface.getCore().getSones();
+               Collection<Sone> sones = webInterface.getCore().getSones();
                Collection<Hit<Sone>> soneHits = getHits(sones, phrases, SoneStringGenerator.COMPLETE_GENERATOR);
 
                Collection<Hit<Post>> postHits = hitCache.getUnchecked(phrases);
@@ -310,7 +310,7 @@ public class SearchPage extends SoneTemplatePage {
         */
        private String getSoneId(String phrase) {
                String soneId = phrase.startsWith("sone://") ? phrase.substring(7) : phrase;
-               return (webInterface.getCore().getSone(soneId) != null) ? soneId : null;
+               return (webInterface.getCore().getSone(soneId).isPresent()) ? soneId : null;
        }
 
        /**
@@ -467,7 +467,7 @@ public class SearchPage extends SoneTemplatePage {
                        if (post.getRecipient().isPresent()) {
                                postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(post.getRecipient().get()));
                        }
-                       for (PostReply reply : Collections2.filter(webInterface.getCore().getReplies(post), Reply.FUTURE_REPLY_FILTER)) {
+                       for (PostReply reply : Collections2.filter(webInterface.getCore().getReplies(post.getId()), Reply.FUTURE_REPLY_FILTER)) {
                                postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(reply.getSone()));
                                postString.append(' ').append(reply.getText());
                        }
@@ -581,7 +581,7 @@ public class SearchPage extends SoneTemplatePage {
 
                        @Override
                        public boolean apply(Hit<?> hit) {
-                               return hit.getScore() > 0;
+                               return (hit != null) && (hit.getScore() > 0);
                        }
 
                };