X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FPost.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FPost.kt;h=d87bd3c2e75518c3c0097928d95a4d8bb031ffec;hp=0000000000000000000000000000000000000000;hb=5c5bee980f9cab5792e34d1c9840f73b8b191830;hpb=faf66247a34f64946990a985d2ea3003465969cb 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 index 0000000..d87bd3c --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/data/Post.kt @@ -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 = comparing(Post::getTime).reversed()