import net.pterodactylus.util.template.Filter;
import net.pterodactylus.util.template.TemplateContext;
-import com.google.common.base.Optional;
-
/**
* {@link Filter} implementation that groups replies by the post the are in
* reply to, returning a map with the post as key and the list of replies as
* All replies from a new-reply notification have posts,
* ListNotificationFilters takes care of that.
*/
- Optional<Post> post = reply.getPost();
- Set<Sone> sones = postSones.get(post.get());
+ Post post = reply.getPost().get();
+ Set<Sone> sones = postSones.get(post);
if (sones == null) {
sones = new HashSet<>();
- postSones.put(post.get(), sones);
+ postSones.put(post, sones);
}
sones.add(reply.getSone());
- Set<PostReply> replies = postReplies.get(post.get());
+ Set<PostReply> replies = postReplies.get(post);
if (replies == null) {
replies = new HashSet<>();
- postReplies.put(post.get(), replies);
+ postReplies.put(post, replies);
}
replies.add(reply);
}
Map<Post, Map<String, Set<?>>> result = new HashMap<>();
for (Entry<Post, Set<Sone>> postEntry : postSones.entrySet()) {
- if (result.containsKey(postEntry.getKey())) {
- continue;
- }
Map<String, Set<?>> postResult = new HashMap<>();
postResult.put("sones", postEntry.getValue());
postResult.put("replies", postReplies.get(postEntry.getKey()));