From: David ‘Bombe’ Roden Date: Sun, 28 Jun 2020 19:23:24 +0000 (+0200) Subject: ♻️ Replace reply visibility filter interface with Kotlin version X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6ddb4dad913e7b06a5ac5f33f73bf8214049bd8e;p=Sone.git ♻️ Replace reply visibility filter interface with Kotlin version --- 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) } + +}