🎨 Use Kotlin arrow type instead of Predicate
[Sone.git] / src / main / java / net / pterodactylus / sone / notify / ListNotificationFilter.java
index 7084e66..76bfbff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - ListNotificationFilters.java - Copyright Â© 2010–2015 David Roden
+ * Sone - ListNotificationFilter.java - Copyright Â© 2010–2020 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
@@ -17,7 +17,7 @@
 
 package net.pterodactylus.sone.notify;
 
-import static com.google.common.collect.FluentIterable.from;
+import static java.util.stream.Collectors.toList;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -36,8 +36,6 @@ import com.google.common.base.Optional;
 
 /**
  * Filter for {@link ListNotification}s.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David â€˜Bombe’ Roden</a>
  */
 @Singleton
 public class ListNotificationFilter {
@@ -67,7 +65,7 @@ public class ListNotificationFilter {
         */
        @SuppressWarnings("unchecked")
        public List<Notification> filterNotifications(Collection<? extends Notification> notifications, Sone currentSone) {
-               List<Notification> filteredNotifications = new ArrayList<Notification>();
+               List<Notification> filteredNotifications = new ArrayList<>();
                for (Notification notification : notifications) {
                        if (notification.getId().equals("new-sone-notification")) {
                                if ((currentSone != null) && !currentSone.getOptions().isShowNewSoneNotifications()) {
@@ -121,14 +119,14 @@ public class ListNotificationFilter {
        @Nonnull
        private Optional<ListNotification<Post>> filterPostNotification(@Nonnull ListNotification<Post> postNotification,
                        @Nullable Sone currentSone) {
-               List<Post> newPosts = from(postNotification.getElements()).filter(postVisibilityFilter.isVisible(currentSone)).toList();
+               List<Post> newPosts = postNotification.getElements().stream().filter(postVisibilityFilter.isVisible(currentSone)).collect(toList());
                if (newPosts.isEmpty()) {
                        return Optional.absent();
                }
                if (newPosts.size() == postNotification.getElements().size()) {
                        return Optional.of(postNotification);
                }
-               ListNotification<Post> filteredNotification = new ListNotification<Post>(postNotification);
+               ListNotification<Post> filteredNotification = new ListNotification<>(postNotification);
                filteredNotification.setElements(newPosts);
                filteredNotification.setLastUpdateTime(postNotification.getLastUpdatedTime());
                return Optional.of(filteredNotification);
@@ -150,14 +148,14 @@ public class ListNotificationFilter {
         */
        private Optional<ListNotification<PostReply>> filterNewReplyNotification(ListNotification<PostReply> newReplyNotification,
                        @Nonnull Sone currentSone) {
-               List<PostReply> newReplies = from(newReplyNotification.getElements()).filter(replyVisibilityFilter.isVisible(currentSone)).toList();
+               List<PostReply> newReplies = newReplyNotification.getElements().stream().filter(replyVisibilityFilter.isVisible(currentSone)).collect(toList());
                if (newReplies.isEmpty()) {
                        return Optional.absent();
                }
                if (newReplies.size() == newReplyNotification.getElements().size()) {
                        return Optional.of(newReplyNotification);
                }
-               ListNotification<PostReply> filteredNotification = new ListNotification<PostReply>(newReplyNotification);
+               ListNotification<PostReply> filteredNotification = new ListNotification<>(newReplyNotification);
                filteredNotification.setElements(newReplies);
                filteredNotification.setLastUpdateTime(newReplyNotification.getLastUpdatedTime());
                return Optional.of(filteredNotification);