aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/api/Binding.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/isxander/yacl3/api/Binding.java')
-rw-r--r--src/main/java/dev/isxander/yacl3/api/Binding.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/main/java/dev/isxander/yacl3/api/Binding.java b/src/main/java/dev/isxander/yacl3/api/Binding.java
index f41b78b..61c59a2 100644
--- a/src/main/java/dev/isxander/yacl3/api/Binding.java
+++ b/src/main/java/dev/isxander/yacl3/api/Binding.java
@@ -6,6 +6,7 @@ import net.minecraft.client.OptionInstance;
import org.apache.commons.lang3.Validate;
import java.util.function.Consumer;
+import java.util.function.Function;
import java.util.function.Supplier;
/**
@@ -19,6 +20,10 @@ public interface Binding<T> {
T defaultValue();
+ default <U> Binding<U> xmap(Function<T, U> to, Function<U, T> from) {
+ return Binding.generic(to.apply(this.defaultValue()), () -> to.apply(this.getValue()), v -> this.setValue(from.apply(v)));
+ }
+
/**
* Creates a generic binding.
*