aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/impl/GenericBindingImpl.java
diff options
context:
space:
mode:
authorisxander <xander@isxander.dev>2024-04-11 18:43:06 +0100
committerisxander <xander@isxander.dev>2024-04-11 18:43:06 +0100
commit04fe933f4c24817100f3101f088accf55a621f8a (patch)
treefeff94ca3ab4484160e69a24f4ee38522381950e /src/main/java/dev/isxander/yacl3/impl/GenericBindingImpl.java
parent831b894fdb7fe3e173d81387c8f6a2402b8ccfa9 (diff)
downloadYetAnotherConfigLib-04fe933f4c24817100f3101f088accf55a621f8a.tar.gz
YetAnotherConfigLib-04fe933f4c24817100f3101f088accf55a621f8a.tar.bz2
YetAnotherConfigLib-04fe933f4c24817100f3101f088accf55a621f8a.zip
Extremely fragile and broken multiversion build with stonecutter
Diffstat (limited to 'src/main/java/dev/isxander/yacl3/impl/GenericBindingImpl.java')
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/GenericBindingImpl.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/dev/isxander/yacl3/impl/GenericBindingImpl.java b/src/main/java/dev/isxander/yacl3/impl/GenericBindingImpl.java
new file mode 100644
index 0000000..972c891
--- /dev/null
+++ b/src/main/java/dev/isxander/yacl3/impl/GenericBindingImpl.java
@@ -0,0 +1,35 @@
+package dev.isxander.yacl3.impl;
+
+import dev.isxander.yacl3.api.Binding;
+
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+public final class GenericBindingImpl<T> implements Binding<T> {
+ private final T def;
+ private final Supplier<T> getter;
+ private final Consumer<T> setter;
+
+ public GenericBindingImpl(T def, Supplier<T> getter, Consumer<T> setting) {
+ this.def = def;
+ this.getter = getter;
+ this.setter = setting;
+ }
+
+
+ @Override
+ public void setValue(T value) {
+ setter.accept(value);
+ }
+
+ @Override
+ public T getValue() {
+ return getter.get();
+ }
+
+ @Override
+ public T defaultValue() {
+ return def;
+ }
+
+}