import static java.util.concurrent.TimeUnit.*;
import static java.util.logging.Logger.getLogger;
import static java.util.stream.Collectors.toList;
-import static net.pterodactylus.sone.data.PostKt.newestFirst;
+import static net.pterodactylus.sone.data.PostKt.newestPostFirst;
import java.io.*;
import java.nio.charset.Charset;
soneProperties.put("name", sone.getName());
soneProperties.put("time", currentTimeMillis());
soneProperties.put("profile", sone.getProfile());
- soneProperties.put("posts", Ordering.from(newestFirst()).sortedCopy(sone.getPosts()));
+ soneProperties.put("posts", Ordering.from(newestPostFirst()).sortedCopy(sone.getPosts()));
soneProperties.put("replies", Ordering.from(Reply.TIME_COMPARATOR).reverse().sortedCopy(sone.getReplies()));
soneProperties.put("likedPostIds", new HashSet<>(sone.getLikedPostIds()));
soneProperties.put("likedReplyIds", new HashSet<>(sone.getLikedReplyIds()));
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.logging.Logger.getLogger;
-import static net.pterodactylus.sone.data.PostKt.newestFirst;
+import static net.pterodactylus.sone.data.PostKt.newestPostFirst;
import static net.pterodactylus.sone.data.SoneKt.*;
import java.net.MalformedURLException;
synchronized (this) {
sortedPosts = new ArrayList<>(posts);
}
- sortedPosts.sort(newestFirst());
+ sortedPosts.sort(newestPostFirst());
return sortedPosts;
}
import freenet.support.SimpleFieldSet;
-import static net.pterodactylus.sone.data.PostKt.newestFirst;
+import static net.pterodactylus.sone.data.PostKt.newestPostFirst;
import static net.pterodactylus.sone.data.PostKt.noFuturePost;
/**
allPosts = Collections2.filter(allPosts, noFuturePost()::invoke);
List<Post> sortedPosts = new ArrayList<>(allPosts);
- sortedPosts.sort(newestFirst());
+ sortedPosts.sort(newestPostFirst());
if (sortedPosts.size() < startPost) {
return new Response("PostFeed", encodePosts(Collections.<Post> emptyList(), "Posts.", false));
/**
* Comparator that orders posts by their time, newest posts first.
*/
-@get:JvmName("newestFirst")
-val newestFirst: Comparator<Post> = comparing(Post::getTime).reversed()
+@get:JvmName("newestPostFirst")
+val newestPostFirst: Comparator<Post> = comparing(Post::getTime).reversed()
fun `newestFirst comparator returns less-than 0 if first is newer than second`() {
val newerPost = createPost(time = 2000)
val olderPost = createPost(time = 1000)
- assertThat(newestFirst.compare(newerPost, olderPost), lessThan(0))
+ assertThat(newestPostFirst.compare(newerPost, olderPost), lessThan(0))
}
@Test
fun `newestFirst comparator returns greater-than 0 if first is older than second`() {
val newerPost = createPost(time = 2000)
val olderPost = createPost(time = 1000)
- assertThat(newestFirst.compare(olderPost, newerPost), greaterThan(0))
+ assertThat(newestPostFirst.compare(olderPost, newerPost), greaterThan(0))
}
@Test
fun `newestFirst comparator returns 0 if first and second are the same age`() {
val post1 = createPost(time = 1000)
val post2 = createPost(time = 1000)
- assertThat(newestFirst.compare(post2, post1), equalTo(0))
+ assertThat(newestPostFirst.compare(post2, post1), equalTo(0))
}
}