Change all copyright headers to include 2012.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Sone.java
index 74ab276..c3287c8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - Sone.java - Copyright © 2010 David Roden
+ * Sone - Sone.java - Copyright © 2010–2012 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -49,6 +49,26 @@ import freenet.keys.FreenetURI;
 public class Sone implements Fingerprintable, Comparable<Sone> {
 
        /**
+        * Enumeration for the possible states of a {@link Sone}.
+        *
+        * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+        */
+       public enum SoneStatus {
+
+               /** The Sone is unknown, i.e. not yet downloaded. */
+               unknown,
+
+               /** The Sone is idle, i.e. not being downloaded or inserted. */
+               idle,
+
+               /** The Sone is currently being inserted. */
+               inserting,
+
+               /** The Sone is currently being downloaded. */
+               downloading,
+       }
+
+       /**
         * The possible values for the “show custom avatars” option.
         *
         * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
@@ -171,12 +191,18 @@ public class Sone implements Fingerprintable, Comparable<Sone> {
        /** The time of the last inserted update. */
        private volatile long time;
 
+       /** The status of this Sone. */
+       private volatile SoneStatus status = SoneStatus.unknown;
+
        /** The profile of this Sone. */
        private volatile Profile profile = new Profile(this);
 
        /** The client used by the Sone. */
        private volatile Client client;
 
+       /** Whether this Sone is known. */
+       private volatile boolean known;
+
        /** All friend Sones. */
        private final Set<String> friendSones = new CopyOnWriteArraySet<String>();
 
@@ -360,6 +386,30 @@ public class Sone implements Fingerprintable, Comparable<Sone> {
        }
 
        /**
+        * Returns the status of this Sone.
+        *
+        * @return The status of this Sone
+        */
+       public SoneStatus getStatus() {
+               return status;
+       }
+
+       /**
+        * Sets the new status of this Sone.
+        *
+        * @param status
+        *            The new status of this Sone
+        * @return This Sone
+        * @throws IllegalArgumentException
+        *             if {@code status} is {@code null}
+        */
+       public Sone setStatus(SoneStatus status) {
+               Validation.begin().isNotNull("Sone Status", status).check();
+               this.status = status;
+               return this;
+       }
+
+       /**
         * Returns a copy of the profile. If you want to update values in the
         * profile of this Sone, update the values in the returned {@link Profile}
         * and use {@link #setProfile(Profile)} to change the profile in this Sone.
@@ -404,6 +454,27 @@ public class Sone implements Fingerprintable, Comparable<Sone> {
        }
 
        /**
+        * Returns whether this Sone is known.
+        *
+        * @return {@code true} if this Sone is known, {@code false} otherwise
+        */
+       public boolean isKnown() {
+               return known;
+       }
+
+       /**
+        * Sets whether this Sone is known.
+        *
+        * @param known
+        *            {@code true} if this Sone is known, {@code false} otherwise
+        * @return This Sone
+        */
+       public Sone setKnown(boolean known) {
+               this.known = known;
+               return this;
+       }
+
+       /**
         * Returns all friend Sones of this Sone.
         *
         * @return The friend Sones of this Sone