Class IntegerCodec

java.lang.Object
io.github.theword.queqiao.core.config.codec.IntegerCodec
All Implemented Interfaces:
ConfigCodec<Integer>

public final class IntegerCodec extends Object implements ConfigCodec<Integer>
整数编解码器

严格类型:8080.0 不会被接受为整数—— 它更可能是用户写错了类型,而不是正常输入。

Since:
0.6.12
  • Field Details

  • Method Details

    • read

      public Integer read(String path, Object raw)
      Description copied from interface: ConfigCodec
      把 YAML 原始值解析为目标类型
      Specified by:
      read in interface ConfigCodec<Integer>
      Parameters:
      path - 配置路径(用于报错)
      raw - 原始值,可能为 null(字段存在但值为空)
      Returns:
      解析结果
    • write

      public Object write(Integer value)
      Description copied from interface: ConfigCodec
      把目标类型转成可写入 YAML 的原始值
      Specified by:
      write in interface ConfigCodec<Integer>
      Parameters:
      value - 目标值
      Returns:
      YAML 可写出的原始值
    • typeName

      public String typeName()
      Description copied from interface: ConfigCodec
      类型名称,用于报错文案(如 integer)
      Specified by:
      typeName in interface ConfigCodec<Integer>
      Returns:
      类型名称
    • copy

      public Integer copy(Integer value)
      Description copied from interface: ConfigCodec
      复制值

      用于保证"默认值"不会在多个 Config 实例之间共享同一个可变对象。 不可变类型直接返回原值。

      Specified by:
      copy in interface ConfigCodec<Integer>
      Parameters:
      value - 目标值
      Returns:
      副本