♻️ Replace reply visibility filter interface with Kotlin version
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 28 Jun 2020 19:23:24 +0000 (21:23 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 28 Jun 2020 19:23:24 +0000 (21:23 +0200)
src/main/java/net/pterodactylus/sone/notify/ReplyVisibilityFilter.java [deleted file]
src/main/kotlin/net/pterodactylus/sone/notify/ReplyVisibilityFilter.kt [new file with mode: 0644]

diff --git a/src/main/java/net/pterodactylus/sone/notify/ReplyVisibilityFilter.java b/src/main/java/net/pterodactylus/sone/notify/ReplyVisibilityFilter.java
deleted file mode 100644 (file)
index 4091dd3..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package net.pterodactylus.sone.notify;
-
-import java.util.function.Predicate;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.pterodactylus.sone.data.PostReply;
-import net.pterodactylus.sone.data.Sone;
-
-import com.google.inject.ImplementedBy;
-
-@ImplementedBy(DefaultReplyVisibilityFilter.class)
-public interface ReplyVisibilityFilter {
-
-       boolean isReplyVisible(@Nullable Sone sone, @Nonnull PostReply reply);
-
-       default Predicate<PostReply> isVisible(@Nullable final Sone currentSone) {
-               return reply -> (reply != null) && isReplyVisible(currentSone, reply);
-       }
-
-}
diff --git a/src/main/kotlin/net/pterodactylus/sone/notify/ReplyVisibilityFilter.kt b/src/main/kotlin/net/pterodactylus/sone/notify/ReplyVisibilityFilter.kt
new file mode 100644 (file)
index 0000000..34018f6
--- /dev/null
@@ -0,0 +1,17 @@
+package net.pterodactylus.sone.notify
+
+import com.google.inject.ImplementedBy
+import net.pterodactylus.sone.data.PostReply
+import net.pterodactylus.sone.data.Sone
+import java.util.function.Predicate
+
+@ImplementedBy(DefaultReplyVisibilityFilter::class)
+interface ReplyVisibilityFilter {
+
+       fun isReplyVisible(sone: Sone?, reply: PostReply): Boolean
+
+       @JvmDefault
+       fun isVisible(currentSone: Sone?): Predicate<PostReply> =
+                       Predicate { reply: PostReply -> isReplyVisible(currentSone, reply) }
+
+}