Use Guava’s predicate instead of utils’ filter.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 16 Jan 2013 07:06:34 +0000 (08:06 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 16 Jan 2013 18:04:10 +0000 (19:04 +0100)
12 files changed:
src/main/java/net/pterodactylus/sone/data/Post.java
src/main/java/net/pterodactylus/sone/data/Reply.java
src/main/java/net/pterodactylus/sone/data/Sone.java
src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
src/main/java/net/pterodactylus/sone/template/PostAccessor.java
src/main/java/net/pterodactylus/sone/web/BookmarksPage.java
src/main/java/net/pterodactylus/sone/web/IndexPage.java
src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java
src/main/java/net/pterodactylus/sone/web/SearchPage.java
src/main/java/net/pterodactylus/sone/web/WebInterface.java
src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java

index f171475..e68846a 100644 (file)
@@ -19,7 +19,7 @@ package net.pterodactylus.sone.data;
 
 import java.util.Comparator;
 
-import net.pterodactylus.util.collection.filter.Filter;
+import com.google.common.base.Predicate;
 
 /**
  * A post is a short message that a user writes in his Sone to let other users
@@ -40,10 +40,10 @@ public interface Post {
        };
 
        /** Filter for posts with timestamps from the future. */
-       public static final Filter<Post> FUTURE_POSTS_FILTER = new Filter<Post>() {
+       public static final Predicate<Post> FUTURE_POSTS_FILTER = new Predicate<Post>() {
 
                @Override
-               public boolean filterObject(Post post) {
+               public boolean apply(Post post) {
                        return post.getTime() <= System.currentTimeMillis();
                }
 
index be60b88..f6e4a2c 100644 (file)
@@ -20,7 +20,7 @@ package net.pterodactylus.sone.data;
 import java.util.Comparator;
 import java.util.UUID;
 
-import net.pterodactylus.util.collection.filter.Filter;
+import com.google.common.base.Predicate;
 
 /**
  * Abstract base class for all replies.
@@ -45,13 +45,13 @@ public abstract class Reply<T extends Reply<T>> {
        };
 
        /** Filter for replies with timestamps from the future. */
-       public static final Filter<Reply<?>> FUTURE_REPLY_FILTER = new Filter<Reply<?>>() {
+       public static final Predicate<Reply<?>> FUTURE_REPLY_FILTER = new Predicate<Reply<?>>() {
 
                /**
                 * {@inheritDoc}
                 */
                @Override
-               public boolean filterObject(Reply<?> reply) {
+               public boolean apply(Reply<?> reply) {
                        return reply.getTime() <= System.currentTimeMillis();
                }
 
index 30dacd5..80032ad 100644 (file)
@@ -32,9 +32,11 @@ import net.pterodactylus.sone.core.Options;
 import net.pterodactylus.sone.freenet.wot.Identity;
 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
 import net.pterodactylus.sone.template.SoneAccessor;
-import net.pterodactylus.util.collection.filter.Filter;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.validation.Validation;
+
+import com.google.common.base.Predicate;
+
 import freenet.keys.FreenetURI;
 
 /**
@@ -141,29 +143,29 @@ public class Sone implements Fingerprintable, Comparable<Sone> {
        };
 
        /** Filter to remove Sones that have not been downloaded. */
-       public static final Filter<Sone> EMPTY_SONE_FILTER = new Filter<Sone>() {
+       public static final Predicate<Sone> EMPTY_SONE_FILTER = new Predicate<Sone>() {
 
                @Override
-               public boolean filterObject(Sone sone) {
+               public boolean apply(Sone sone) {
                        return sone.getTime() != 0;
                }
        };
 
        /** Filter that matches all {@link Sone#isLocal() local Sones}. */
-       public static final Filter<Sone> LOCAL_SONE_FILTER = new Filter<Sone>() {
+       public static final Predicate<Sone> LOCAL_SONE_FILTER = new Predicate<Sone>() {
 
                @Override
-               public boolean filterObject(Sone sone) {
+               public boolean apply(Sone sone) {
                        return sone.getIdentity() instanceof OwnIdentity;
                }
 
        };
 
        /** Filter that matches Sones that have at least one album. */
-       public static final Filter<Sone> HAS_ALBUM_FILTER = new Filter<Sone>() {
+       public static final Predicate<Sone> HAS_ALBUM_FILTER = new Predicate<Sone>() {
 
                @Override
-               public boolean filterObject(Sone sone) {
+               public boolean apply(Sone sone) {
                        return !sone.getAlbums().isEmpty();
                }
        };
index 1eb488e..0b1e47b 100644 (file)
@@ -32,7 +32,9 @@ import net.pterodactylus.sone.freenet.fcp.AbstractCommand;
 import net.pterodactylus.sone.freenet.fcp.Command;
 import net.pterodactylus.sone.freenet.fcp.FcpException;
 import net.pterodactylus.sone.template.SoneAccessor;
-import net.pterodactylus.util.collection.filter.Filters;
+
+import com.google.common.collect.Collections2;
+
 import freenet.node.FSParseException;
 import freenet.support.SimpleFieldSet;
 
@@ -335,7 +337,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
                        String postPrefix = prefix + postIndex++;
                        postBuilder.put(encodePost(post, postPrefix + ".", includeReplies));
                        if (includeReplies) {
-                               postBuilder.put(encodeReplies(Filters.filteredList(core.getReplies(post), Reply.FUTURE_REPLY_FILTER), postPrefix + "."));
+                               postBuilder.put(encodeReplies(Collections2.filter(core.getReplies(post), Reply.FUTURE_REPLY_FILTER), postPrefix + "."));
                        }
                }
 
index 781bed2..bec162f 100644 (file)
 package net.pterodactylus.sone.fcp;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.fcp.FcpException;
-import net.pterodactylus.util.collection.filter.Filters;
+
+import com.google.common.collect.Collections2;
+
 import freenet.support.SimpleFieldSet;
 import freenet.support.api.Bucket;
 
@@ -58,7 +60,7 @@ public class GetPostFeedCommand extends AbstractSoneCommand {
                int startPost = getInt(parameters, "StartPost", 0);
                int maxPosts = getInt(parameters, "MaxPosts", -1);
 
-               Set<Post> allPosts = new HashSet<Post>();
+               Collection<Post> allPosts = new HashSet<Post>();
                allPosts.addAll(sone.getPosts());
                for (String friendSoneId : sone.getFriends()) {
                        if (!getCore().hasSone(friendSoneId)) {
@@ -67,7 +69,7 @@ public class GetPostFeedCommand extends AbstractSoneCommand {
                        allPosts.addAll(getCore().getSone(friendSoneId, false).getPosts());
                }
                allPosts.addAll(getCore().getDirectedPosts(sone));
-               allPosts = Filters.filteredSet(allPosts, Post.FUTURE_POSTS_FILTER);
+               allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER);
 
                List<Post> sortedPosts = new ArrayList<Post>(allPosts);
                Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
index d05b074..6064017 100644 (file)
@@ -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), Reply.FUTURE_REPLY_FILTER);
                } else if (member.equals("likes")) {
                        return core.getLikes(post);
                } else if (member.equals("liked")) {
index 95dfd65..66f7236 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.web;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
@@ -25,12 +26,13 @@ import java.util.Set;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.collection.Pagination;
-import net.pterodactylus.util.collection.filter.Filter;
-import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
 /**
  * Page that lets the user browse all his bookmarked posts.
  *
@@ -61,10 +63,10 @@ public class BookmarksPage extends SoneTemplatePage {
        protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                Set<Post> allPosts = webInterface.getCore().getBookmarkedPosts();
-               Set<Post> loadedPosts = Filters.filteredSet(allPosts, new Filter<Post>() {
+               Collection<Post> loadedPosts = Collections2.filter(allPosts, new Predicate<Post>() {
 
                        @Override
-                       public boolean filterObject(Post post) {
+                       public boolean apply(Post post) {
                                return post.getSone() != null;
                        }
                });
index 8a5d1b5..baa5609 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.web;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
@@ -26,12 +27,13 @@ import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.collection.Pagination;
-import net.pterodactylus.util.collection.filter.Filter;
-import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
 /**
  * The index page shows the main page of Sone. This page will contain the posts
  * of all friends of the current user.
@@ -61,7 +63,7 @@ public class IndexPage extends SoneTemplatePage {
        protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                final Sone currentSone = getCurrentSone(request.getToadletContext());
-               List<Post> allPosts = new ArrayList<Post>();
+               Collection<Post> allPosts = new ArrayList<Post>();
                allPosts.addAll(currentSone.getPosts());
                for (String friendSoneId : currentSone.getFriends()) {
                        if (!webInterface.getCore().hasSone(friendSoneId)) {
@@ -76,16 +78,17 @@ public class IndexPage extends SoneTemplatePage {
                                }
                        }
                }
-               allPosts = Filters.filteredList(allPosts, new Filter<Post>() {
+               allPosts = Collections2.filter(allPosts, new Predicate<Post>() {
 
                        @Override
-                       public boolean filterObject(Post post) {
+                       public boolean apply(Post post) {
                                return ListNotificationFilters.isPostVisible(currentSone, post);
                        }
                });
-               allPosts = Filters.filteredList(allPosts, Post.FUTURE_POSTS_FILTER);
-               Collections.sort(allPosts, Post.TIME_COMPARATOR);
-               Pagination<Post> pagination = new Pagination<Post>(allPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
+               allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER);
+               List<Post> sortedPosts = new ArrayList<Post>(allPosts);
+               Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
+               Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
                templateContext.set("pagination", pagination);
                templateContext.set("posts", pagination.getItems());
        }
index 00568da..bc928c4 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.web;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
@@ -25,12 +26,14 @@ import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.collection.ReverseComparator;
-import net.pterodactylus.util.collection.filter.Filter;
-import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
+
 /**
  * This page shows all known Sones.
  *
@@ -67,74 +70,77 @@ public class KnownSonesPage extends SoneTemplatePage {
                templateContext.set("order", (sortOrder != null) ? sortOrder : "asc");
                templateContext.set("filter", filter);
                final Sone currentSone = getCurrentSone(request.getToadletContext(), false);
-               List<Sone> knownSones = Filters.filteredList(new ArrayList<Sone>(webInterface.getCore().getSones()), Sone.EMPTY_SONE_FILTER);
+               Collection<Sone> knownSones = Collections2.filter(webInterface.getCore().getSones(), Sone.EMPTY_SONE_FILTER);
                if ((currentSone != null) && "followed".equals(filter)) {
-                       knownSones = Filters.filteredList(knownSones, new Filter<Sone>() {
+                       knownSones = Collections2.filter(knownSones, new Predicate<Sone>() {
 
                                @Override
-                               public boolean filterObject(Sone sone) {
+                               public boolean apply(Sone sone) {
                                        return currentSone.hasFriend(sone.getId());
                                }
                        });
                } else if ((currentSone != null) && "not-followed".equals(filter)) {
-                       knownSones = Filters.filteredList(knownSones, new Filter<Sone>() {
+                       knownSones = Collections2.filter(knownSones, new Predicate<Sone>() {
 
                                @Override
-                               public boolean filterObject(Sone sone) {
+                               public boolean apply(Sone sone) {
                                        return !currentSone.hasFriend(sone.getId());
                                }
                        });
                } else if ("new".equals(filter)) {
-                       knownSones = Filters.filteredList(knownSones, new Filter<Sone>() {
+                       knownSones = Collections2.filter(knownSones, new Predicate<Sone>() {
+
                                /**
                                 * {@inheritDoc}
                                 */
                                @Override
-                               public boolean filterObject(Sone sone) {
+                               public boolean apply(Sone sone) {
                                        return !sone.isKnown();
                                }
                        });
                } else if ("not-new".equals(filter)) {
-                       knownSones = Filters.filteredList(knownSones, new Filter<Sone>() {
+                       knownSones = Collections2.filter(knownSones, new Predicate<Sone>() {
+
                                /**
                                 * {@inheritDoc}
                                 */
                                @Override
-                               public boolean filterObject(Sone sone) {
+                               public boolean apply(Sone sone) {
                                        return sone.isKnown();
                                }
                        });
                } else if ("own".equals(filter)) {
-                       knownSones = Filters.filteredList(knownSones, Sone.LOCAL_SONE_FILTER);
+                       knownSones = Collections2.filter(knownSones, Sone.LOCAL_SONE_FILTER);
                } else if ("not-own".equals(filter)) {
-                       knownSones = Filters.filteredList(knownSones, Filters.reverseFilter(Sone.LOCAL_SONE_FILTER));
+                       knownSones = Collections2.filter(knownSones, Predicates.not(Sone.LOCAL_SONE_FILTER));
                }
+               List<Sone> sortedSones = new ArrayList<Sone>(knownSones);
                if ("activity".equals(sortField)) {
                        if ("asc".equals(sortOrder)) {
-                               Collections.sort(knownSones, new ReverseComparator<Sone>(Sone.LAST_ACTIVITY_COMPARATOR));
+                               Collections.sort(sortedSones, new ReverseComparator<Sone>(Sone.LAST_ACTIVITY_COMPARATOR));
                        } else {
-                               Collections.sort(knownSones, Sone.LAST_ACTIVITY_COMPARATOR);
+                               Collections.sort(sortedSones, Sone.LAST_ACTIVITY_COMPARATOR);
                        }
                } else if ("posts".equals(sortField)) {
                        if ("asc".equals(sortOrder)) {
-                               Collections.sort(knownSones, new ReverseComparator<Sone>(Sone.POST_COUNT_COMPARATOR));
+                               Collections.sort(sortedSones, new ReverseComparator<Sone>(Sone.POST_COUNT_COMPARATOR));
                        } else {
-                               Collections.sort(knownSones, Sone.POST_COUNT_COMPARATOR);
+                               Collections.sort(sortedSones, Sone.POST_COUNT_COMPARATOR);
                        }
                } else if ("images".equals(sortField)) {
                        if ("asc".equals(sortOrder)) {
-                               Collections.sort(knownSones, new ReverseComparator<Sone>(Sone.IMAGE_COUNT_COMPARATOR));
+                               Collections.sort(sortedSones, new ReverseComparator<Sone>(Sone.IMAGE_COUNT_COMPARATOR));
                        } else {
-                               Collections.sort(knownSones, Sone.IMAGE_COUNT_COMPARATOR);
+                               Collections.sort(sortedSones, Sone.IMAGE_COUNT_COMPARATOR);
                        }
                } else {
                        if ("desc".equals(sortOrder)) {
-                               Collections.sort(knownSones, new ReverseComparator<Sone>(Sone.NICE_NAME_COMPARATOR));
+                               Collections.sort(sortedSones, new ReverseComparator<Sone>(Sone.NICE_NAME_COMPARATOR));
                        } else {
-                               Collections.sort(knownSones, Sone.NICE_NAME_COMPARATOR);
+                               Collections.sort(sortedSones, Sone.NICE_NAME_COMPARATOR);
                        }
                }
-               Pagination<Sone> sonePagination = new Pagination<Sone>(knownSones, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
+               Pagination<Sone> sonePagination = new Pagination<Sone>(sortedSones, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
                templateContext.set("pagination", sonePagination);
                templateContext.set("knownSones", sonePagination.getItems());
        }
index 6d300ed..002e4f2 100644 (file)
@@ -42,8 +42,6 @@ import net.pterodactylus.util.cache.MemoryCache;
 import net.pterodactylus.util.cache.ValueRetriever;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.collection.TimedMap;
-import net.pterodactylus.util.collection.filter.Filter;
-import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.collection.mapper.Mapper;
 import net.pterodactylus.util.collection.mapper.Mappers;
 import net.pterodactylus.util.logging.Logging;
@@ -53,6 +51,9 @@ import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.text.StringEscaper;
 import net.pterodactylus.util.text.TextException;
 
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
 /**
  * This page lets the user search for posts and replies that contain certain
  * words.
@@ -74,7 +75,7 @@ public class SearchPage extends SoneTemplatePage {
                        for (Sone sone : webInterface.getCore().getSones()) {
                                posts.addAll(sone.getPosts());
                        }
-                       return new DefaultCacheItem<Set<Hit<Post>>>(getHits(Filters.filteredSet(posts, Post.FUTURE_POSTS_FILTER), phrases, new PostStringGenerator()));
+                       return new DefaultCacheItem<Set<Hit<Post>>>(getHits(Collections2.filter(posts, Post.FUTURE_POSTS_FILTER), phrases, new PostStringGenerator()));
                }
 
        }, new TimedMap<List<Phrase>, CacheItem<Set<Hit<Post>>>>(300000));
@@ -132,9 +133,9 @@ public class SearchPage extends SoneTemplatePage {
                }
 
                Set<Sone> sones = webInterface.getCore().getSones();
-               Set<Hit<Sone>> soneHits = getHits(sones, phrases, SoneStringGenerator.COMPLETE_GENERATOR);
+               Collection<Hit<Sone>> soneHits = getHits(sones, phrases, SoneStringGenerator.COMPLETE_GENERATOR);
 
-               Set<Hit<Post>> postHits;
+               Collection<Hit<Post>> postHits;
                try {
                        postHits = hitCache.get(phrases);
                } catch (CacheException ce1) {
@@ -144,8 +145,8 @@ public class SearchPage extends SoneTemplatePage {
                }
 
                /* now filter. */
-               soneHits = Filters.filteredSet(soneHits, Hit.POSITIVE_FILTER);
-               postHits = Filters.filteredSet(postHits, Hit.POSITIVE_FILTER);
+               soneHits = Collections2.filter(soneHits, Hit.POSITIVE_FILTER);
+               postHits = Collections2.filter(postHits, Hit.POSITIVE_FILTER);
 
                /* now sort. */
                List<Hit<Sone>> sortedSoneHits = new ArrayList<Hit<Sone>>(soneHits);
@@ -472,7 +473,7 @@ public class SearchPage extends SoneTemplatePage {
                        if (post.getRecipient() != null) {
                                postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(post.getRecipient()));
                        }
-                       for (PostReply reply : Filters.filteredList(webInterface.getCore().getReplies(post), Reply.FUTURE_REPLY_FILTER)) {
+                       for (PostReply reply : Collections2.filter(webInterface.getCore().getReplies(post), Reply.FUTURE_REPLY_FILTER)) {
                                postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(reply.getSone()));
                                postString.append(' ').append(reply.getText());
                        }
@@ -582,10 +583,10 @@ public class SearchPage extends SoneTemplatePage {
        private static class Hit<T> {
 
                /** Filter for {@link Hit}s with a score of more than 0. */
-               public static final Filter<Hit<?>> POSITIVE_FILTER = new Filter<Hit<?>>() {
+               public static final Predicate<Hit<?>> POSITIVE_FILTER = new Predicate<Hit<?>>() {
 
                        @Override
-                       public boolean filterObject(Hit<?> hit) {
+                       public boolean apply(Hit<?> hit) {
                                return hit.getScore() > 0;
                        }
 
index 20b1f82..436ed5f 100644 (file)
@@ -104,7 +104,6 @@ import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.sone.web.page.PageToadlet;
 import net.pterodactylus.sone.web.page.PageToadletFactory;
 import net.pterodactylus.util.collection.SetBuilder;
-import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.NotificationManager;
@@ -132,6 +131,7 @@ import net.pterodactylus.util.web.RedirectPage;
 import net.pterodactylus.util.web.StaticPage;
 import net.pterodactylus.util.web.TemplatePage;
 
+import com.google.common.collect.Collections2;
 import com.google.inject.Inject;
 
 import freenet.clients.http.SessionManager;
@@ -737,7 +737,7 @@ public class WebInterface implements CoreListener {
         *            The text to parse
         * @return All mentioned local Sones
         */
-       private Set<Sone> getMentionedSones(String text) {
+       private Collection<Sone> getMentionedSones(String text) {
                /* we need no context to find mentioned Sones. */
                Set<Sone> mentionedSones = new HashSet<Sone>();
                try {
@@ -749,7 +749,7 @@ public class WebInterface implements CoreListener {
                } catch (IOException ioe1) {
                        logger.log(Level.WARNING, String.format("Could not parse post text: %s", text), ioe1);
                }
-               return Filters.filteredSet(mentionedSones, Sone.LOCAL_SONE_FILTER);
+               return Collections2.filter(mentionedSones, Sone.LOCAL_SONE_FILTER);
        }
 
        /**
index 4c61f89..b1ac58a 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax;
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
@@ -32,13 +33,14 @@ import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.template.SoneAccessor;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.web.page.FreenetRequest;
-import net.pterodactylus.util.collection.filter.Filter;
-import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.json.JsonArray;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.object.HashCode;
 
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
 /**
  * The “get status” AJAX handler returns all information that is necessary to
  * update the web interface in real-time.
@@ -89,12 +91,12 @@ public class GetStatusAjaxPage extends JsonPage {
                Collections.sort(notifications, Notification.CREATED_TIME_SORTER);
                int notificationHash = HashCode.hashCode(notifications);
                /* load new posts. */
-               Set<Post> newPosts = webInterface.getNewPosts();
+               Collection<Post> newPosts = webInterface.getNewPosts();
                if (currentSone != null) {
-                       newPosts = Filters.filteredSet(newPosts, new Filter<Post>() {
+                       newPosts = Collections2.filter(newPosts, new Predicate<Post>() {
 
                                @Override
-                               public boolean filterObject(Post post) {
+                               public boolean apply(Post post) {
                                        return ListNotificationFilters.isPostVisible(currentSone, post);
                                }
 
@@ -110,22 +112,22 @@ public class GetStatusAjaxPage extends JsonPage {
                        jsonPosts.add(jsonPost);
                }
                /* load new replies. */
-               Set<PostReply> newReplies = webInterface.getNewReplies();
+               Collection<PostReply> newReplies = webInterface.getNewReplies();
                if (currentSone != null) {
-                       newReplies = Filters.filteredSet(newReplies, new Filter<PostReply>() {
+                       newReplies = Collections2.filter(newReplies, new Predicate<PostReply>() {
 
                                @Override
-                               public boolean filterObject(PostReply reply) {
+                               public boolean apply(PostReply reply) {
                                        return ListNotificationFilters.isReplyVisible(currentSone, reply);
                                }
 
                        });
                }
                /* remove replies to unknown posts. */
-               newReplies = Filters.filteredSet(newReplies, new Filter<PostReply>() {
+               newReplies = Collections2.filter(newReplies, new Predicate<PostReply>() {
 
                        @Override
-                       public boolean filterObject(PostReply reply) {
+                       public boolean apply(PostReply reply) {
                                return (reply.getPost() != null) && (reply.getPost().getSone() != null);
                        }
                });