Further reduce dependencies on a Sone for downloading.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Sone.java
index d7a7dee..1b76588 100644 (file)
@@ -27,13 +27,17 @@ import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
 
-import net.pterodactylus.sone.core.Options;
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
 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;
 
@@ -144,7 +148,7 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
 
                @Override
                public boolean apply(Sone sone) {
-                       return (sone == null) ? false : sone.getTime() != 0;
+                       return (sone != null) && (sone.getTime() != 0);
                }
        };
 
@@ -153,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) && (sone.getIdentity() instanceof OwnIdentity);
                }
 
        };
@@ -163,10 +167,21 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
 
                @Override
                public boolean apply(Sone sone) {
-                       return (sone == null) ? false : !sone.getRootAlbum().getAlbums().isEmpty();
+                       return (sone != null) && !sone.getRootAlbum().getAlbums().isEmpty();
                }
        };
 
+       public static final Function<Sone, String> toSoneXmlUri =
+                       new Function<Sone, String>() {
+                               @Nonnull
+                               @Override
+                               public String apply(@Nullable Sone input) {
+                                       return input.getRequestUri()
+                                                       .setMetaString(new String[] { "sone.xml" })
+                                                       .toString();
+                               }
+                       };
+
        /**
         * Returns the identity of this Sone.
         *
@@ -535,7 +550,7 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
         *
         * @return The options of this Sone
         */
-       Options getOptions();
+       SoneOptions getOptions();
 
        /**
         * Sets the options of this Sone.
@@ -544,6 +559,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
         *              The options of this Sone
         */
        /* TODO - remove this method again, maybe add an option provider */
-       void setOptions(Options options);
+       void setOptions(SoneOptions options);
 
 }