X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=aa4a1552292f010919c1f0748321817ab571539e;hp=1a8c7df3888ccfa9b7b851608f6cf10d1a392056;hb=a23c4f218c3adf236d89d5927cae37d6e6e4feda;hpb=b8545de14af229c6b557ef2229ee0166459d3a16 diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 1a8c7df..aa4a155 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -27,8 +27,10 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import net.pterodactylus.sone.core.Options; import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.template.SoneAccessor; +import net.pterodactylus.util.filter.Filter; import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.validation.Validation; import freenet.keys.FreenetURI; @@ -57,6 +59,15 @@ public class Sone implements Fingerprintable, Comparable { }; + /** Filter to remove Sones that have not been downloaded. */ + public static final Filter EMPTY_SONE_FILTER = new Filter() { + + @Override + public boolean filterObject(Sone sone) { + return sone.getTime() != 0; + } + }; + /** The logger. */ private static final Logger logger = Logging.getLogger(Sone.class); @@ -103,6 +114,9 @@ public class Sone implements Fingerprintable, Comparable { /** The albums of this Sone. */ private final List albums = Collections.synchronizedList(new ArrayList()); + /** Sone-specific options. */ + private final Options options = new Options(); + /** * Creates a new Sone. * @@ -391,8 +405,10 @@ public class Sone implements Fingerprintable, Comparable { * @return This Sone (for method chaining) */ public synchronized Sone setPosts(Collection posts) { - this.posts.clear(); - this.posts.addAll(posts); + synchronized (this) { + this.posts.clear(); + this.posts.addAll(posts); + } return this; } @@ -629,6 +645,15 @@ public class Sone implements Fingerprintable, Comparable { albums.remove(album); } + /** + * Returns Sone-specific options. + * + * @return The options of this Sone + */ + public Options getOptions() { + return options; + } + // // FINGERPRINTABLE METHODS //