Return friends as Collection, not as List.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Sone.java
index 083b3a5..acf9031 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;
@@ -33,7 +34,6 @@ import net.pterodactylus.sone.database.AlbumBuilder;
 import net.pterodactylus.sone.database.PostBuilder;
 import net.pterodactylus.sone.database.PostReplyBuilder;
 import net.pterodactylus.sone.freenet.wot.Identity;
-import net.pterodactylus.sone.freenet.wot.OwnIdentity;
 import net.pterodactylus.sone.template.SoneAccessor;
 
 import com.google.common.base.Function;
@@ -157,7 +157,7 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
 
                @Override
                public boolean apply(Sone sone) {
-                       return (sone == null) ? false : sone.getIdentity() instanceof OwnIdentity;
+                       return (sone == null) ? false : sone.isLocal();
                }
 
        };
@@ -178,6 +178,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 +274,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
@@ -296,7 +294,7 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
         *
         * @return The friend Sones of this Sone
         */
-       List<String> getFriends();
+       Collection<String> getFriends();
 
        /**
         * Returns whether this Sone has the given Sone as a friend Sone.