aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/OptionAccess.java
blob: c55afe4e9f620aff173c2eed1e84f8d7fb3e1c8e (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
package dev.isxander.yacl3.config.v2.api.autogen;

import dev.isxander.yacl3.api.Option;
import org.jetbrains.annotations.Nullable;

import java.util.function.Consumer;

/**
 * An accessor to all options that are auto-generated
 * by the config system.
 */
public interface OptionAccess {
    /**
     * Gets an option by its field name.
     * This could be null if the option hasn't been created yet. It is created
     * in order of the fields in the class, so if you are trying to get an option
     * lower-down in the class, this will return null.
     *
     * @param fieldName the exact, case-sensitive name of the field.
     * @return the created option, or {@code null} if it hasn't been created yet.
     */
    @Nullable Option<?> getOption(String fieldName);

    /**
     * Schedules an operation to be performed on an option.
     * If the option has already been created, the consumer will be
     * accepted immediately upon calling this method, if not, it will
     * be added to the queue of operations to be performed on the option
     * once it does get created.
     *
     * @param fieldName the exact, case-sensitive name of the field.
     * @param optionConsumer the operation to perform on the option.
     */
    void scheduleOptionOperation(String fieldName, Consumer<Option<?>> optionConsumer);
}