Update year in copyright lines
[Sone.git] / src / main / java / net / pterodactylus / sone / template / ReplyGroupFilter.java
index 709ffbc..c093e6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - ReplyGroupFilter.java - Copyright © 2010–2015 David Roden
+ * Sone - ReplyGroupFilter.java - Copyright © 2010–2019 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
@@ -30,14 +30,10 @@ import net.pterodactylus.sone.data.Sone;
 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
  * values.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public class ReplyGroupFilter implements Filter {
 
@@ -48,33 +44,30 @@ public class ReplyGroupFilter implements Filter {
        public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
                @SuppressWarnings("unchecked")
                List<PostReply> allReplies = (List<PostReply>) data;
-               Map<Post, Set<Sone>> postSones = new HashMap<Post, Set<Sone>>();
-               Map<Post, Set<PostReply>> postReplies = new HashMap<Post, Set<PostReply>>();
+               Map<Post, Set<Sone>> postSones = new HashMap<>();
+               Map<Post, Set<PostReply>> postReplies = new HashMap<>();
                for (PostReply reply : allReplies) {
                        /*
                         * 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<Sone>();
-                               postSones.put(post.get(), sones);
+                               sones = new HashSet<>();
+                               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<PostReply>();
-                               postReplies.put(post.get(), replies);
+                               replies = new HashSet<>();
+                               postReplies.put(post, replies);
                        }
                        replies.add(reply);
                }
-               Map<Post, Map<String, Set<?>>> result = new HashMap<Post, Map<String, Set<?>>>();
+               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<String, Set<?>>();
+                       Map<String, Set<?>> postResult = new HashMap<>();
                        postResult.put("sones", postEntry.getValue());
                        postResult.put("replies", postReplies.get(postEntry.getKey()));
                        result.put(postEntry.getKey(), postResult);