X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=c01e120abef7da91bcbd2b71378f329acf520c44;hb=1380d276bf5886e320f89cea232a6db7e4cdb7b8;hp=d7a7dee7b2d342c943983f96e295672227e91303;hpb=3d888e800617335535c1a4b2cbac3e02acfdde34;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 d7a7dee..c01e120 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.data; import static com.google.common.collect.FluentIterable.from; import static java.util.Arrays.asList; +import static net.pterodactylus.sone.core.SoneUri.create; import static net.pterodactylus.sone.data.Album.FLATTENER; import static net.pterodactylus.sone.data.Album.IMAGES; @@ -28,14 +29,17 @@ import java.util.List; import java.util.Set; import net.pterodactylus.sone.core.Options; +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 freenet.keys.FreenetURI; - +import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.primitives.Ints; +import freenet.keys.FreenetURI; /** * A Sone defines everything about a user: her profile, her status updates, her @@ -167,6 +171,13 @@ public interface Sone extends Identified, Fingerprintable, Comparable { } }; + public static final Function TO_FREENET_URI = new Function() { + @Override + public FreenetURI apply(Sone sone) { + return (sone == null) ? null : create(sone.getIdentity().getRequestUri()); + } + }; + /** * Returns the identity of this Sone. * @@ -175,18 +186,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 @@ -201,38 +200,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable { boolean isLocal(); /** - * Returns the request URI of this Sone. - * - * @return The request URI of this 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 - */ - 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 @@ -546,4 +513,10 @@ public interface Sone extends Identified, Fingerprintable, Comparable { /* TODO - remove this method again, maybe add an option provider */ void setOptions(Options options); + AlbumBuilder newAlbumBuilder() throws IllegalStateException; + + PostBuilder newPostBuilder(); + + PostReplyBuilder newPostReplyBuilder(String postId) throws IllegalStateException; + }