aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/impl/SafeBinding.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/isxander/yacl3/impl/SafeBinding.java')
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/SafeBinding.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/dev/isxander/yacl3/impl/SafeBinding.java b/src/main/java/dev/isxander/yacl3/impl/SafeBinding.java
new file mode 100644
index 0000000..c55d2be
--- /dev/null
+++ b/src/main/java/dev/isxander/yacl3/impl/SafeBinding.java
@@ -0,0 +1,29 @@
+package dev.isxander.yacl3.impl;
+
+import dev.isxander.yacl3.api.Binding;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Objects;
+
+public class SafeBinding<T> implements Binding<T> {
+ private final Binding<T> binding;
+
+ public SafeBinding(Binding<T> binding) {
+ this.binding = binding;
+ }
+
+ @Override
+ public @NotNull T getValue() {
+ return Objects.requireNonNull(binding.getValue());
+ }
+
+ @Override
+ public void setValue(@NotNull T value) {
+ binding.setValue(Objects.requireNonNull(value));
+ }
+
+ @Override
+ public @NotNull T defaultValue() {
+ return Objects.requireNonNull(binding.defaultValue());
+ }
+}