Class MergeUtils


  • public abstract class MergeUtils
    extends Object
    Utility to process merge keys (https://yaml.org/type/merge.html) of the MappingNode
    • Constructor Detail

      • MergeUtils

        public MergeUtils()
    • Method Detail

      • asMappingNode

        public abstract MappingNode asMappingNode​(Node node)
        Converts the specified node into a MappingNode.

        This method is designed to transform various types of Node into a MappingNode, enabling further processing such as merging of keys.

        Parameters:
        node - The node to be transformed.
        Returns:
        A MappingNode representation of the input node.
      • flatten

        public List<NodeTuple> flatten​(MappingNode node)
        Processes and resolves merge keys in a MappingNode, merging resolved key/values into the node.

        Implements the YAML merge key feature by examining the nodes within the provided node and 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 in node and the the earliest occurrences in the merging ones.

        Parameters:
        node - The MappingNode to process for merge keys.
        Returns:
        A list of NodeTuple containing the merged keys and values.
        See Also:
        YAML Merge Key Specification