diff options
author | isXander <xandersmith2008@gmail.com> | 2022-11-27 18:17:36 +0000 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2022-11-27 18:17:36 +0000 |
commit | d163b9128d760e53e34fd6c08dbf782fa3d50c51 (patch) | |
tree | b9ea79bb99bf52ea7de9d059cc05900270ff88d4 /src/main/java/dev/isxander/yacl/api/Binding.java | |
parent | c26d3a89caae20f1a91898202d91de8dc90da5ad (diff) | |
download | YetAnotherConfigLib-d163b9128d760e53e34fd6c08dbf782fa3d50c51.tar.gz YetAnotherConfigLib-d163b9128d760e53e34fd6c08dbf782fa3d50c51.tar.bz2 YetAnotherConfigLib-d163b9128d760e53e34fd6c08dbf782fa3d50c51.zip |
split sourcesets
Diffstat (limited to 'src/main/java/dev/isxander/yacl/api/Binding.java')
-rw-r--r-- | src/main/java/dev/isxander/yacl/api/Binding.java | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/src/main/java/dev/isxander/yacl/api/Binding.java b/src/main/java/dev/isxander/yacl/api/Binding.java deleted file mode 100644 index 395beb2..0000000 --- a/src/main/java/dev/isxander/yacl/api/Binding.java +++ /dev/null @@ -1,64 +0,0 @@ -package dev.isxander.yacl.api; - -import dev.isxander.yacl.impl.GenericBindingImpl; -import dev.isxander.yacl.mixin.SimpleOptionAccessor; -import net.minecraft.client.option.SimpleOption; -import org.apache.commons.lang3.Validate; - -import java.util.function.Consumer; -import java.util.function.Supplier; - -/** - * Controls modifying the bound option. - * Provides the default value, a setter and a getter. - */ -public interface Binding<T> { - void setValue(T value); - - T getValue(); - - T defaultValue(); - - /** - * Creates a generic binding. - * - * @param def default value of the option, used to reset - * @param getter should return the current value of the option - * @param setter should set the option to the supplied value - */ - static <T> Binding<T> generic(T def, Supplier<T> getter, Consumer<T> setter) { - Validate.notNull(def, "`def` must not be null"); - Validate.notNull(getter, "`getter` must not be null"); - Validate.notNull(setter, "`setter` must not be null"); - - return new GenericBindingImpl<>(def, getter, setter); - } - - /** - * Creates a {@link Binding} for Minecraft's {@link SimpleOption} - */ - static <T> Binding<T> minecraft(SimpleOption<T> minecraftOption) { - Validate.notNull(minecraftOption, "`minecraftOption` must not be null"); - - return new GenericBindingImpl<>( - ((SimpleOptionAccessor<T>) (Object) minecraftOption).getDefaultValue(), - minecraftOption::getValue, - minecraftOption::setValue - ); - } - - /** - * Creates an immutable binding that has no default and cannot be modified. - * - * @param value the value for the binding - */ - static <T> Binding<T> immutable(T value) { - Validate.notNull(value, "`value` must not be null"); - - return new GenericBindingImpl<>( - value, - () -> value, - changed -> {} - ); - } -} |