From 6ddb4dad913e7b06a5ac5f33f73bf8214049bd8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 28 Jun 2020 21:23:24 +0200 Subject: [PATCH] =?utf8?q?=E2=99=BB=EF=B8=8F=20Replace=20reply=20visibilit?= =?utf8?q?y=20filter=20interface=20with=20Kotlin=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sone/notify/ReplyVisibilityFilter.java | 21 --------------------- .../sone/notify/ReplyVisibilityFilter.kt | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 21 deletions(-) delete mode 100644 src/main/java/net/pterodactylus/sone/notify/ReplyVisibilityFilter.java create mode 100644 src/main/kotlin/net/pterodactylus/sone/notify/ReplyVisibilityFilter.kt 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 index 4091dd3..0000000 --- a/src/main/java/net/pterodactylus/sone/notify/ReplyVisibilityFilter.java +++ /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 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 index 0000000..34018f6 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/notify/ReplyVisibilityFilter.kt @@ -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 = + Predicate { reply: PostReply -> isReplyVisible(currentSone, reply) } + +} -- 2.7.4