Includes the time in the state.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Jan 2013 10:54:37 +0000 (11:54 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 6 Jan 2013 10:54:37 +0000 (11:54 +0100)
src/main/java/net/pterodactylus/reactor/State.java
src/main/java/net/pterodactylus/reactor/states/AbstractState.java

index 9e2face..cc37909 100644 (file)
@@ -25,6 +25,14 @@ package net.pterodactylus.reactor;
 public interface State {
 
        /**
 public interface State {
 
        /**
+        * Returns the time when this state was retrieved.
+        *
+        * @return The time when this state was retrieved (in millseconds since Jan
+        *         1, 1970 UTC)
+        */
+       long time();
+
+       /**
         * Whether the state was successfully retrieved. This method should only
         * return {@code true} if a meaningful result could be retrieved; if e. g. a
         * service is currently not reachable, this method should return false
         * Whether the state was successfully retrieved. This method should only
         * return {@code true} if a meaningful result could be retrieved; if e. g. a
         * service is currently not reachable, this method should return false
index e35c933..f8d6f69 100644 (file)
@@ -27,6 +27,9 @@ import net.pterodactylus.reactor.State;
  */
 public abstract class AbstractState implements State {
 
  */
 public abstract class AbstractState implements State {
 
+       /** The time of this state. */
+       private final long time;
+
        /** Whether the state was successfully retrieved. */
        private final boolean success;
 
        /** Whether the state was successfully retrieved. */
        private final boolean success;
 
@@ -71,6 +74,7 @@ public abstract class AbstractState implements State {
         *            The exception that occured while retrieving the state
         */
        protected AbstractState(boolean success, Throwable exception) {
         *            The exception that occured while retrieving the state
         */
        protected AbstractState(boolean success, Throwable exception) {
+               this.time = System.currentTimeMillis();
                this.success = success;
                this.exception = exception;
        }
                this.success = success;
                this.exception = exception;
        }
@@ -83,6 +87,14 @@ public abstract class AbstractState implements State {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
+       public long time() {
+               return time;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
        public boolean success() {
                return success;
        }
        public boolean success() {
                return success;
        }