Don’t set insert URI of a Sone, let it be generated from the identity.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Sone.java
index 1b76588..c27e8cc 100644 (file)
@@ -23,6 +23,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;
@@ -182,6 +183,23 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
                                }
                        };
 
+       public static final Function<Sone, List<Album>> toAllAlbums = new Function<Sone, List<Album>>() {
+               @Override
+               public List<Album> apply(@Nullable Sone sone) {
+                       return (sone == null) ? Collections.<Album>emptyList() : FLATTENER.apply(
+                                       sone.getRootAlbum());
+               }
+       };
+
+       public static final Function<Sone, List<Image>> toAllImages = new Function<Sone, List<Image>>() {
+               @Override
+               public List<Image> apply(@Nullable Sone sone) {
+                       return (sone == null) ? Collections.<Image>emptyList() :
+                                       from(FLATTENER.apply(sone.getRootAlbum()))
+                                                       .transformAndConcat(IMAGES).toList();
+               }
+       };
+
        /**
         * Returns the identity of this Sone.
         *
@@ -190,18 +208,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
        Identity getIdentity();
 
        /**
-        * Sets the identity of this Sone. The {@link Identity#getId() ID} of the
-        * identity has to match this Sone’s {@link #getId()}.
-        *
-        * @param identity
-        *              The identity of this Sone
-        * @return This Sone (for method chaining)
-        * @throws IllegalArgumentException
-        *              if the ID of the identity does not match this Sone’s ID
-        */
-       Sone setIdentity(Identity identity) throws IllegalArgumentException;
-
-       /**
         * Returns the name of this Sone.
         *
         * @return The name of this Sone
@@ -239,15 +245,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
        FreenetURI getInsertUri();
 
        /**
-        * Sets the insert URI of this Sone.
-        *
-        * @param insertUri
-        *              The insert URI of this Sone
-        * @return This Sone (for method chaining)
-        */
-       Sone setInsertUri(FreenetURI insertUri);
-
-       /**
         * Returns the latest edition of this Sone.
         *
         * @return The latest edition of this Sone