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;
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.
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));
}
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) {
}
/* 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);
*/
private String getReplyPostId(String phrase) {
String replyId = phrase.startsWith("reply://") ? phrase.substring(8) : phrase;
- return (webInterface.getCore().getReply(replyId, false) != null) ? webInterface.getCore().getReply(replyId, false).getPost().getId() : null;
+ return (webInterface.getCore().getPostReply(replyId, false) != null) ? webInterface.getCore().getPostReply(replyId, false).getPost().getId() : null;
}
/**
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());
}
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;
}