boolean isReplyVisible(@Nullable Sone sone, @Nonnull PostReply reply);
- Predicate<PostReply> isVisible(@Nullable final Sone currentSone);
+ default Predicate<PostReply> isVisible(@Nullable final Sone currentSone) {
+ return reply -> (reply != null) && isReplyVisible(currentSone, reply);
+ }
}
val showAllReplies = createReplyVisibilityFilter(showAllPosts) { _, _ -> true }
val showNoReplies = createReplyVisibilityFilter(showAllPosts) { _, _ -> false }
-private fun createReplyVisibilityFilter(postVisibilityFilter: PostVisibilityFilter, visible: (Sone?, PostReply) -> Boolean) = object : DefaultReplyVisibilityFilter(postVisibilityFilter) {
+private fun createReplyVisibilityFilter(postVisibilityFilter: PostVisibilityFilter, visible: (Sone?, PostReply) -> Boolean): ReplyVisibilityFilter = object : DefaultReplyVisibilityFilter(postVisibilityFilter) {
override fun isReplyVisible(sone: Sone?, reply: PostReply) = visible(sone, reply)
- override fun isVisible(currentSone: Sone?) = Predicate<PostReply> { r -> r != null && isReplyVisible(currentSone, r) }
}