import java.util.concurrent.atomic.AtomicReference;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import net.pterodactylus.util.config.ConfigurationException;
import net.pterodactylus.util.config.Value;
private final AtomicReference<T> value = new AtomicReference<T>();
- public TestValue(T originalValue) {
+ public TestValue(@Nullable T originalValue) {
value.set(originalValue);
}
@Override
+ @Nullable
public T getValue() throws ConfigurationException {
return value.get();
}
@Override
- public T getValue(T defaultValue) {
+ @Nullable
+ public T getValue(@Nullable T defaultValue) {
final T realValue = value.get();
return (realValue != null) ? realValue : defaultValue;
}
@Override
- public void setValue(T newValue) throws ConfigurationException {
+ public void setValue(@Nullable T newValue) throws ConfigurationException {
value.set(newValue);
}
}
@Override
+ @Nonnull
public String toString() {
return String.valueOf(value.get());
}
- public static <T> Value<T> from(T value) {
+ @Nonnull
+ public static <T> Value<T> from(@Nullable T value) {
return new TestValue<T>(value);
}