}
/**
- * Returns all posts that have the given Sone as recipient.
- *
- * @see Post#getRecipient()
- * @param recipient
- * The recipient of the posts
- * @return All posts that have the given Sone as recipient
+ * {@inheritDoc}
*/
- public Set<Post> getDirectedPosts(Sone recipient) {
- checkNotNull(recipient, "recipient must not be null");
- Set<Post> directedPosts = new HashSet<Post>();
+ @Override
+ public Collection<Post> getDirectedPosts(final String recipientId) {
+ checkNotNull(recipientId, "recipient must not be null");
synchronized (posts) {
- for (Post post : posts.values()) {
- if (recipient.equals(post.getRecipient())) {
- directedPosts.add(post);
+ return Collections2.filter(posts.values(), new Predicate<Post>() {
+
+ @Override
+ public boolean apply(Post post) {
+ return (post.getRecipient() != null) && (post.getRecipient().getId().equals(recipientId));
}
- }
+ });
}
- return directedPosts;
}
-
/**
* Returns a post reply builder.
*
}
allPosts.addAll(getCore().getSone(friendSoneId).getPosts());
}
- allPosts.addAll(getCore().getDirectedPosts(sone));
+ allPosts.addAll(getCore().getDirectedPosts(sone.getId()));
allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER);
List<Post> sortedPosts = new ArrayList<Post>(allPosts);
return;
}
List<Post> sonePosts = sone.getPosts();
- sonePosts.addAll(webInterface.getCore().getDirectedPosts(sone));
+ sonePosts.addAll(webInterface.getCore().getDirectedPosts(sone.getId()));
Collections.sort(sonePosts, Post.TIME_COMPARATOR);
Pagination<Post> postPagination = new Pagination<Post>(sonePosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("postPage"), 0));
templateContext.set("postPagination", postPagination);