From: David ‘Bombe’ Roden Date: Wed, 16 Oct 2013 19:03:59 +0000 (+0200) Subject: Add function that transforms a post into its replies. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=0ae4db6f172db754840808595719c595dcc7b7bc;p=Sone.git Add function that transforms a post into its replies. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Post.java b/src/main/java/net/pterodactylus/sone/data/Post.java index 145170d..20bf518 100644 --- a/src/main/java/net/pterodactylus/sone/data/Post.java +++ b/src/main/java/net/pterodactylus/sone/data/Post.java @@ -17,9 +17,11 @@ package net.pterodactylus.sone.data; +import java.util.Collections; import java.util.Comparator; import java.util.List; +import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.base.Predicate; @@ -51,6 +53,13 @@ public interface Post extends Identified { }; + public static final Function> TO_REPLIES = new Function>() { + @Override + public List apply(Post post) { + return (post == null) ? Collections.emptyList() : post.getReplies(); + } + }; + // // ACCESSORS //