Class ConfigKey.Builder<T>

java.lang.Object
io.github.theword.queqiao.core.config.schema.ConfigKey.Builder<T>
Type Parameters:
T - 值类型
Enclosing class:
ConfigKey<T>

public static final class ConfigKey.Builder<T> extends Object
ConfigKey 构建器
  • Method Details

    • defaultValue

      public ConfigKey.Builder<T> defaultValue(T value)
      指定默认值

      可变类型(List/Map 等)也安全:读取默认值时会经 codec 复制。 若默认值构造代价较高,用 defaultValueSupplier(Supplier)。

      Parameters:
      value - 默认值
      Returns:
      构建器
    • defaultValueSupplier

      public ConfigKey.Builder<T> defaultValueSupplier(Supplier<? extends T> supplier)
      用 Supplier 指定默认值(适合可变类型,保证每次都新建)
      Parameters:
      supplier - 默认值提供者
      Returns:
      构建器
    • validator

      public ConfigKey.Builder<T> validator(ConfigValidator<? super T> validator)
      指定校验器
      Parameters:
      validator - 校验器
      Returns:
      构建器
    • comment

      public ConfigKey.Builder<T> comment(String... commentLines)
      指定注释行(会写入生成的 config.yml)
      Parameters:
      commentLines - 注释行
      Returns:
      构建器
    • build

      public ConfigKey<T> build()
      构建
      Returns:
      配置项定义