Class MergeUtils
- java.lang.Object
-
- org.yaml.snakeyaml.util.MergeUtils
-
public abstract class MergeUtils extends java.lang.ObjectUtility to process merge keys (https://yaml.org/type/merge.html) of the MappingNode
-
-
Constructor Summary
Constructors Constructor Description MergeUtils()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract MappingNodeasMappingNode(Node node)Converts the specifiednodeinto aMappingNode.private Tuple<java.util.List<NodeTuple>,java.util.Set<java.lang.String>>filter(java.util.List<NodeTuple> mergables, java.util.Set<java.lang.String> filter)Filters outNodeTuples withScalarNodekeys that are present in the provided filter set.java.util.List<NodeTuple>flatten(MappingNode node)Processes and resolves merge keys in aMappingNode, merging resolved key/values into the node.
-
-
-
Method Detail
-
asMappingNode
public abstract MappingNode asMappingNode(Node node)
Converts the specifiednodeinto aMappingNode.This method is designed to transform various types of
Nodeinto aMappingNode, enabling further processing such as merging of keys.- Parameters:
node- The node to be transformed.- Returns:
- A
MappingNoderepresentation of the inputnode.
-
flatten
public java.util.List<NodeTuple> flatten(MappingNode node)
Processes and resolves merge keys in aMappingNode, merging resolved key/values into the node.Implements the YAML merge key feature by examining the nodes within the provided
nodeand merging keys from referenced by "merge key" map(s) into the current mapping as per the YAML specification. Handling of duplicate keys is defined by the order of appearance in the mapping node, with priority given to the keys defined innodeand the the earliest occurrences in the merging ones.- Parameters:
node- The MappingNode to process for merge keys.- Returns:
- A list of
NodeTuplecontaining the merged keys and values. - See Also:
- YAML Merge Key Specification
-
filter
private Tuple<java.util.List<NodeTuple>,java.util.Set<java.lang.String>> filter(java.util.List<NodeTuple> mergables, java.util.Set<java.lang.String> filter)
Filters outNodeTuples withScalarNodekeys that are present in the provided filter set.This utility method supports the
flatten(MappingNode)method by filtering out node tuples based on their key's presence in a set of strings. This ensures that the returned list of NodeTuples does not contain any keys that are present in the filter set. The set of strings returned alongside the list represents the keys of the NodeTuples in the returned list, facilitating the identification of newly added keys as part of the merge process.- Parameters:
mergables- The list of NodeTuples to process.filter- A set of string values used as a filter. NodeTuples with keys in this set are omitted.- Returns:
- A tuple of a list of filtered NodeTuples and a set containing the keys of the NodeTuples in the returned list.
-
-