Add function that transforms a post into its replies.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 16 Oct 2013 19:03:59 +0000 (21:03 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:28 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/data/Post.java

index 145170d..20bf518 100644 (file)
 
 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<Post, List<PostReply>> TO_REPLIES = new Function<Post, List<PostReply>>() {
+               @Override
+               public List<PostReply> apply(Post post) {
+                       return (post == null) ? Collections.<PostReply>emptyList() : post.getReplies();
+               }
+       };
+
        //
        // ACCESSORS
        //