Enum Class MergeStrategy

java.lang.Object
java.lang.Enum<MergeStrategy>
cloud.opencode.base.yml.merge.MergeStrategy
All Implemented Interfaces:
Serializable, Comparable<MergeStrategy>, Constable

public enum MergeStrategy extends Enum<MergeStrategy>
Merge Strategy - Defines how YAML documents are merged 合并策略 - 定义 YAML 文档如何合并

This enum defines different strategies for merging YAML documents.

此枚举定义了合并 YAML 文档的不同策略。

Features | 主要功能:

  • Override, keep-first, deep merge, list append, unique merge, and fail-on-conflict - 覆盖、保留首个、深度合并、列表追加、唯一合并和冲突失败

Usage Examples | 使用示例:

Map<String, Object> merged = YmlMerger.merge(base, overlay, MergeStrategy.DEEP_MERGE);

Security | 安全性:

  • Thread-safe: Yes (enum constants are immutable) - 线程安全: 是(枚举常量不可变)
  • Null-safe: N/A - 空值安全: 不适用
Since:
JDK 25, opencode-base-yml V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Enum Constant Details

    • OVERRIDE

      public static final MergeStrategy OVERRIDE
      Override values (later wins) 覆盖值(后者优先)
    • KEEP_FIRST

      public static final MergeStrategy KEEP_FIRST
      Keep first value (earlier wins) 保留第一个值(先者优先)
    • DEEP_MERGE

      public static final MergeStrategy DEEP_MERGE
      Deep merge maps recursively 递归深度合并映射
    • APPEND_LISTS

      public static final MergeStrategy APPEND_LISTS
      Append lists instead of replacing 追加列表而不是替换
    • MERGE_LISTS_UNIQUE

      public static final MergeStrategy MERGE_LISTS_UNIQUE
      Merge lists by removing duplicates 通过去重合并列表
    • FAIL_ON_CONFLICT

      public static final MergeStrategy FAIL_ON_CONFLICT
      Fail on conflict 冲突时失败
  • Method Details

    • values

      public static MergeStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static MergeStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null