Class YmlConfig

java.lang.Object
cloud.opencode.base.yml.YmlConfig

public final class YmlConfig extends Object
YAML Configuration - Configuration options for YAML processing YAML 配置 - YAML 处理的配置选项

This class provides configuration options for YAML parsing and dumping.

此类提供 YAML 解析和输出的配置选项。

Features | 主要功能:

  • Configurable indent size and flow/scalar styles - 可配置缩进大小和流/标量风格
  • Safe mode with alias, depth, and size limits - 带别名、深度和大小限制的安全模式
  • Duplicate key policy control - 重复键策略控制
  • Builder pattern for flexible construction - 构建器模式实现灵活构造

Usage Examples | 使用示例:

// Create custom configuration
YmlConfig config = YmlConfig.builder()
    .indent(4)
    .prettyPrint(true)
    .safeMode(true)
    .build();

// Use defaults
YmlConfig config = YmlConfig.defaults();

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构建后不可变)
  • Null-safe: Yes (builder uses safe defaults) - 空值安全: 是(构建器使用安全默认值)
Since:
JDK 25, opencode-base-yml V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • defaults

      public static YmlConfig defaults()
      Creates the default configuration. 创建默认配置。
      Returns:
      the default configuration | 默认配置
    • builder

      public static YmlConfig.Builder builder()
      Creates a configuration builder. 创建配置构建器。
      Returns:
      a new builder | 新构建器
    • getIndent

      public int getIndent()
      Gets the indent size. 获取缩进大小。
      Returns:
      the indent spaces | 缩进空格数
    • isPrettyPrint

      public boolean isPrettyPrint()
      Checks if pretty print is enabled. 检查是否启用美化打印。
      Returns:
      true if enabled | 如果启用则返回 true
    • isAllowDuplicateKeys

      public boolean isAllowDuplicateKeys()
      Checks if duplicate keys are allowed. 检查是否允许重复键。
      Returns:
      true if allowed | 如果允许则返回 true
    • isSafeMode

      public boolean isSafeMode()
      Checks if safe mode is enabled. 检查是否启用安全模式。
      Returns:
      true if enabled | 如果启用则返回 true
    • getMaxAliasesForCollections

      public int getMaxAliasesForCollections()
      Gets the maximum number of aliases for collections. 获取集合的最大别名数。
      Returns:
      the maximum aliases | 最大别名数
    • getMaxNestingDepth

      public int getMaxNestingDepth()
      Gets the maximum nesting depth. 获取最大嵌套深度。
      Returns:
      the maximum depth | 最大深度
    • getMaxDocumentSize

      public long getMaxDocumentSize()
      Gets the maximum document size in bytes. 获取最大文档大小(字节)。
      Returns:
      the maximum size | 最大大小
    • getDefaultFlowStyle

      public YmlConfig.FlowStyle getDefaultFlowStyle()
      Gets the default flow style. 获取默认流风格。
      Returns:
      the flow style | 流风格
    • getDefaultScalarStyle

      public YmlConfig.ScalarStyle getDefaultScalarStyle()
      Gets the default scalar style. 获取默认标量风格。
      Returns:
      the scalar style | 标量风格
    • isStrictTypes

      public boolean isStrictTypes()
      Checks if strict types mode is enabled. 检查是否启用严格类型模式。

      When enabled, YAML 1.1 boolean values (YES/NO/ON/OFF/y/n/Y/N) are treated as strings instead of being converted to booleans.

      启用时,YAML 1.1 布尔值(YES/NO/ON/OFF/y/n/Y/N)将被视为字符串, 而不会被转换为布尔值。

      Returns:
      true if strict types is enabled | 如果启用严格类型模式则返回 true