Add a function to transform a Sone into its posts.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Sone.java
index 083b3a5..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.
         *
@@ -267,15 +275,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
        Client getClient();
 
        /**
-        * Sets the client used by this Sone.
-        *
-        * @param client
-        *              The client used by this Sone, or {@code null}
-        * @return This Sone (for method chaining)
-        */
-       Sone setClient(Client client);
-
-       /**
         * Returns whether this Sone is known.
         *
         * @return {@code true} if this Sone is known, {@code false} otherwise