X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=441112a99f1a78cd84aa58e0e72724ab9db29f23;hb=df0abbdc635a8b927474515bb100882e6d850336;hp=1b76588502033fc45ca88cc57ad98873cbd9b24c;hpb=fdffe49b10613e1d9caacdf62ab99bca06edf3e1;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java
index 1b76588..441112a 100644
--- a/src/main/java/net/pterodactylus/sone/data/Sone.java
+++ b/src/main/java/net/pterodactylus/sone/data/Sone.java
@@ -23,11 +23,11 @@ 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;
-import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -35,6 +35,7 @@ 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.Optional;
import freenet.keys.FreenetURI;
import com.google.common.base.Function;
@@ -47,7 +48,7 @@ import com.google.common.primitives.Ints;
*
* @author David âBombeâ Roden
*/
-public interface Sone extends Identified, Fingerprintable, Comparable {
+public interface Sone extends Fingerprintable, Comparable {
/**
* Enumeration for the possible states of a {@link Sone}.
@@ -171,17 +172,32 @@ public interface Sone extends Identified, Fingerprintable, Comparable {
}
};
- public static final Function toSoneXmlUri =
- new Function() {
- @Nonnull
- @Override
- public String apply(@Nullable Sone input) {
- return input.getRequestUri()
- .setMetaString(new String[] { "sone.xml" })
- .toString();
- }
- };
+ public static final Function> toAllAlbums = new Function>() {
+ @Override
+ public List apply(@Nullable Sone sone) {
+ return (sone == null) ? Collections.emptyList() : FLATTENER.apply(
+ sone.getRootAlbum());
+ }
+ };
+
+ public static final Function> toAllImages = new Function>() {
+ @Override
+ public List apply(@Nullable Sone sone) {
+ return (sone == null) ? Collections.emptyList() :
+ from(FLATTENER.apply(sone.getRootAlbum()))
+ .transformAndConcat(IMAGES).toList();
+ }
+ };
+ Function> toAllPosts = new Function>() {
+ @Override
+ public Collection apply(@Nullable Sone sone) {
+ return (sone != null) ? sone.getPosts() : Collections.emptyList();
+ }
+ };
+
+ String getId();
+
/**
* Returns the identity of this Sone.
*
@@ -190,18 +206,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable {
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
@@ -223,15 +227,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable {
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
@@ -239,15 +234,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable {
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
@@ -354,7 +340,7 @@ public interface Sone extends Identified, Fingerprintable, Comparable {
*
* @return The friend Sones of this Sone
*/
- List getFriends();
+ Collection getFriends();
/**
* Returns whether this Sone has the given Sone as a friend Sone.
@@ -367,24 +353,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable {
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
@@ -544,6 +512,7 @@ public interface Sone extends Identified, Fingerprintable, Comparable {
* @return The root album of this Sone
*/
Album getRootAlbum();
+ Optional getImageByInternalId(final String internalId);
/**
* Returns Sone-specific options.