X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=bca789501669e16b84576861661fe7397e7abdb6;hb=0a4b6fc252003c71f4bdef09560e87982838d9c8;hp=8d270c3b09e4fd914220acc7bc034b59cc42df25;hpb=83f434470c6fb4d604c04a69c873d30b5fac5ec9;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 8d270c3..bca7895 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -30,11 +30,14 @@ import java.util.Comparator; import java.util.List; import java.util.Set; +import javax.annotation.Nullable; + 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 freenet.keys.FreenetURI; @@ -108,6 +111,13 @@ public interface Sone extends Identified, Fingerprintable, Comparable { }; + public static final Function TO_NICE_NAME = new Function() { + @Override + public String apply(Sone sone) { + return (sone == null) ? null : getNiceName(sone); + } + }; + /** Comparator that sorts Sones by last activity (least recent active first). */ public static final Comparator LAST_ACTIVITY_COMPARATOR = new Comparator() { @@ -179,6 +189,13 @@ public interface Sone extends Identified, Fingerprintable, Comparable { } }; + public static final Function TO_INSERT_URI = new Function() { + @Override + public FreenetURI apply(@Nullable Sone sone) { + return ((sone == null) || !sone.isLocal()) ? null : create(((OwnIdentity) sone.getIdentity()).getInsertUri()); + } + }; + public static final Function> TO_POSTS = new Function>() { @Override public List apply(Sone sone) {