🔀 Merge branch 'release/v82'
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / data / Post.kt
diff --git a/src/main/kotlin/net/pterodactylus/sone/data/Post.kt b/src/main/kotlin/net/pterodactylus/sone/data/Post.kt
new file mode 100644 (file)
index 0000000..d87bd3c
--- /dev/null
@@ -0,0 +1,16 @@
+package net.pterodactylus.sone.data
+
+import java.util.Comparator.comparing
+
+/**
+ * Predicate that returns whether a post is _not_ from the future,
+ * i.e. whether it should be visible now.
+ */
+@get:JvmName("noFuturePost")
+val noFuturePost: (Post) -> Boolean = { it.time <= System.currentTimeMillis() }
+
+/**
+ * Comparator that orders posts by their time, newest posts first.
+ */
+@get:JvmName("newestPostFirst")
+val newestPostFirst: Comparator<Post> = comparing(Post::getTime).reversed()