Move friend-related functionality into the database.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Sone.java
index 6df84df..27f2cb1 100644 (file)
@@ -28,7 +28,6 @@ import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
 
-import javax.annotation.Nonnegative;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
@@ -191,6 +190,15 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
                }
        };
 
+       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.
         *
@@ -199,18 +207,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
@@ -232,15 +228,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
        FreenetURI getRequestUri();
 
        /**
-        * Sets the request URI of this Sone.
-        *
-        * @param requestUri
-        *              The request URI of this Sone
-        * @return This Sone (for method chaining)
-        */
-       Sone setRequestUri(FreenetURI requestUri);
-
-       /**
         * Returns the insert URI of this Sone.
         *
         * @return The insert URI of this Sone
@@ -248,15 +235,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
@@ -376,24 +354,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
        boolean hasFriend(String friendSoneId);
 
        /**
-        * Adds the given Sone as a friend Sone.
-        *
-        * @param friendSone
-        *              The friend Sone to add
-        * @return This Sone (for method chaining)
-        */
-       Sone addFriend(String friendSone);
-
-       /**
-        * Removes the given Sone as a friend Sone.
-        *
-        * @param friendSoneId
-        *              The ID of the friend Sone to remove
-        * @return This Sone (for method chaining)
-        */
-       Sone removeFriend(String friendSoneId);
-
-       /**
         * Returns the list of posts of this Sone, sorted by time, newest first.
         *
         * @return All posts of this Sone