Add a function to transform a Sone into its posts.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 28 Oct 2013 20:52:35 +0000 (21:52 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:48 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/data/Sone.java

index 989c6a1..a8830f8 100644 (file)
@@ -24,6 +24,7 @@ import static net.pterodactylus.sone.data.Album.FLATTENER;
 import static net.pterodactylus.sone.data.Album.IMAGES;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
@@ -178,6 +179,13 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
                }
        };
 
+       public static final Function<Sone, List<Post>> TO_POSTS = new Function<Sone, List<Post>>() {
+               @Override
+               public List<Post> apply(Sone sone) {
+                       return (sone == null) ? Collections.<Post>emptyList() : sone.getPosts();
+               }
+       };
+
        /**
         * Returns the identity of this Sone.
         *