Override some methods from Object to provide better interoperability with tests.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 25 Nov 2014 20:27:03 +0000 (21:27 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 25 Nov 2014 20:28:05 +0000 (21:28 +0100)
src/test/java/net/pterodactylus/sone/TestValue.java

index 4f3058b..dd923d3 100644 (file)
@@ -5,11 +5,13 @@ import java.util.concurrent.atomic.AtomicReference;
 import net.pterodactylus.util.config.ConfigurationException;
 import net.pterodactylus.util.config.Value;
 
+import com.google.common.base.Objects;
+
 /**
-* Simple {@link Value} implementation.
-*
-* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
-*/
+ * Simple {@link Value} implementation.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
 public class TestValue<T> implements Value<T> {
 
        private final AtomicReference<T> value = new AtomicReference<T>();
@@ -34,4 +36,20 @@ public class TestValue<T> implements Value<T> {
                value.set(newValue);
        }
 
+       @Override
+       public int hashCode() {
+               return value.hashCode();
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               return (obj instanceof TestValue) && Objects.equal(value.get(),
+                               ((TestValue) obj).value.get());
+       }
+
+       @Override
+       public String toString() {
+               return String.valueOf(value.get());
+       }
+
 }