blob: c22d796bd1e74d87ada6edb3e6e2635dc8e7c7f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package dev.isxander.yacl3.config.v3;
import dev.isxander.yacl3.api.Binding;
import org.jetbrains.annotations.ApiStatus;
import java.util.function.Consumer;
import java.util.function.UnaryOperator;
@ApiStatus.Experimental
public interface ConfigEntry<T> extends ReadonlyConfigEntry<T> {
void set(T value);
T defaultValue();
@Override
ConfigEntry<T> modifyGet(UnaryOperator<T> modifier);
@Override
default ConfigEntry<T> onGet(Consumer<T> consumer) {
return this.modifyGet(v -> {
consumer.accept(v);
return v;
});
}
ConfigEntry<T> modifySet(UnaryOperator<T> modifier);
default ConfigEntry<T> onSet(Consumer<T> consumer) {
return this.modifySet(v -> {
consumer.accept(v);
return v;
});
}
default Binding<T> asBinding() {
return Binding.generic(this.defaultValue(), this::get, this::set);
}
}
|