Class YmlMerger
java.lang.Object
cloud.opencode.base.yml.merge.YmlMerger
YAML Merger - Merges multiple YAML documents
YAML 合并器 - 合并多个 YAML 文档
This class provides utilities for merging YAML data structures.
此类提供合并 YAML 数据结构的工具。
Features | 主要功能:
- Deep merge of nested YAML maps - 嵌套 YAML 映射的深度合并
- Multiple merge strategies (override, keep-first, append, unique, fail-on-conflict) - 多种合并策略
- Merge varargs, arrays, or lists of maps - 合并可变参数、数组或映射列表
Usage Examples | 使用示例:
// Merge two documents
Map<String, Object> result = YmlMerger.merge(base, overlay);
// Merge with strategy
Map<String, Object> result = YmlMerger.merge(base, overlay, MergeStrategy.DEEP_MERGE);
// Merge multiple documents
Map<String, Object> result = YmlMerger.mergeAll(doc1, doc2, doc3);
Security | 安全性:
- Thread-safe: Yes (stateless utility class) - 线程安全: 是(无状态工具类)
- Null-safe: Yes (null maps treated as empty) - 空值安全: 是(空映射视为空)
- Since:
- JDK 25, opencode-base-yml V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionMerges two maps with default strategy (DEEP_MERGE).Merges two maps with the specified strategy.mergeAll(MergeStrategy strategy, Map<String, Object>... maps) Merges multiple maps with the specified strategy.Merges a list of maps.Merges a list of maps with the specified strategy.Merges multiple maps.
-
Method Details
-
merge
-
merge
public static Map<String,Object> merge(Map<String, Object> base, Map<String, Object> overlay, MergeStrategy strategy) Merges two maps with the specified strategy. 使用指定策略合并两个映射。- Parameters:
base- the base map | 基础映射overlay- the overlay map | 覆盖映射strategy- the merge strategy | 合并策略- Returns:
- the merged map | 合并后的映射
-
mergeAll
-
mergeAll
@SafeVarargs public static Map<String,Object> mergeAll(MergeStrategy strategy, Map<String, Object>... maps) Merges multiple maps with the specified strategy. 使用指定策略合并多个映射。- Parameters:
strategy- the merge strategy | 合并策略maps- the maps to merge | 要合并的映射- Returns:
- the merged map | 合并后的映射
-
mergeAll
-
mergeAll
-