Use “isLoaded” method to check whether a post is loaded.
[Sone.git] / src / main / java / net / pterodactylus / sone / template / PostAccessor.java
index d05b074..78db678 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - PostAccessor.java - Copyright © 2010–2012 David Roden
+ * Sone - PostAccessor.java - Copyright © 2010–2013 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
@@ -21,10 +21,11 @@ import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.template.ReflectionAccessor;
 import net.pterodactylus.util.template.TemplateContext;
 
+import com.google.common.collect.Collections2;
+
 /**
  * Accessor for {@link Post} objects that adds additional properties:
  * <dl>
@@ -56,7 +57,7 @@ public class PostAccessor extends ReflectionAccessor {
        public Object get(TemplateContext templateContext, Object object, String member) {
                Post post = (Post) object;
                if ("replies".equals(member)) {
-                       return Filters.filteredList(core.getReplies(post), Reply.FUTURE_REPLY_FILTER);
+                       return Collections2.filter(core.getReplies(post.getId()), Reply.FUTURE_REPLY_FILTER);
                } else if (member.equals("likes")) {
                        return core.getLikes(post);
                } else if (member.equals("liked")) {
@@ -66,8 +67,6 @@ public class PostAccessor extends ReflectionAccessor {
                        return !post.isKnown();
                } else if (member.equals("bookmarked")) {
                        return core.isBookmarked(post);
-               } else if (member.equals("loaded")) {
-                       return post.getSone() != null;
                }
                return super.get(templateContext, object, member);
        }