blob: 7f5985311916e8dcd55934dbaee4522b48efe7da (
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
|
package dev.isxander.yacl3.config.v3;
import org.jetbrains.annotations.ApiStatus;
import java.util.function.Function;
import java.util.function.UnaryOperator;
@ApiStatus.Experimental
public abstract class AbstractReadonlyConfigEntry<T> implements ReadonlyConfigEntry<T> {
private final String fieldName;
private Function<T, T> getModifier;
public AbstractReadonlyConfigEntry(String fieldName) {
this.fieldName = fieldName;
this.getModifier = UnaryOperator.identity();
}
@Override
public String fieldName() {
return fieldName;
}
@Override
public T get() {
return this.getModifier.apply(this.innerGet());
}
protected abstract T innerGet();
@Override
public ReadonlyConfigEntry<T> modifyGet(UnaryOperator<T> modifier) {
this.getModifier = this.getModifier.andThen(modifier);
return this;
}
}
|