X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2FTestValue.java;fp=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2FTestValue.java;h=4f3058b06460d65b6691c39a5dd92aa8ef8b0634;hb=dfc936c18f048843bd0c47553713e752e9824658;hp=0000000000000000000000000000000000000000;hpb=a4e39098c822302a52142aca3245fa535b29c942;p=Sone.git
diff --git a/src/test/java/net/pterodactylus/sone/TestValue.java b/src/test/java/net/pterodactylus/sone/TestValue.java
new file mode 100644
index 0000000..4f3058b
--- /dev/null
+++ b/src/test/java/net/pterodactylus/sone/TestValue.java
@@ -0,0 +1,37 @@
+package net.pterodactylus.sone;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import net.pterodactylus.util.config.ConfigurationException;
+import net.pterodactylus.util.config.Value;
+
+/**
+* Simple {@link Value} implementation.
+*
+* @author David âBombeâ Roden
+*/
+public class TestValue implements Value {
+
+ private final AtomicReference value = new AtomicReference();
+
+ public TestValue(T originalValue) {
+ value.set(originalValue);
+ }
+
+ @Override
+ public T getValue() throws ConfigurationException {
+ return value.get();
+ }
+
+ @Override
+ public T getValue(T defaultValue) {
+ final T realValue = value.get();
+ return (realValue != null) ? realValue : defaultValue;
+ }
+
+ @Override
+ public void setValue(T newValue) throws ConfigurationException {
+ value.set(newValue);
+ }
+
+}