Bring image-management up to speed.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Sone.java
index 1a8c7df..aa4a155 100644 (file)
@@ -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<Sone> {
 
        };
 
+       /** Filter to remove Sones that have not been downloaded. */
+       public static final Filter<Sone> EMPTY_SONE_FILTER = new Filter<Sone>() {
+
+               @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<Sone> {
        /** The albums of this Sone. */
        private final List<Album> albums = Collections.synchronizedList(new ArrayList<Album>());
 
+       /** Sone-specific options. */
+       private final Options options = new Options();
+
        /**
         * Creates a new Sone.
         *
@@ -391,8 +405,10 @@ public class Sone implements Fingerprintable, Comparable<Sone> {
         * @return This Sone (for method chaining)
         */
        public synchronized Sone setPosts(Collection<Post> 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<Sone> {
                albums.remove(album);
        }
 
+       /**
+        * Returns Sone-specific options.
+        *
+        * @return The options of this Sone
+        */
+       public Options getOptions() {
+               return options;
+       }
+
        //
        // FINGERPRINTABLE METHODS
        //