Class MergedYamlMapping

  • All Implemented Interfaces:
    YamlMapping, YamlNode, Comparable<YamlNode>

    public final class MergedYamlMapping
    extends BaseYamlMapping
    Merge two YAML Mappings into a single one. Very useful in implementing Updating of an existing YamlMapping. Use it like this:
         final YamlMapping original = ...;
         final YamlMapping changed = ...;
         final YamlMapping merged = new MergedYamlMapping(
             original, changed, true|false
         );
         //or, via the Supplier constructor:
         final YamlMapping merged = new MergedYamlMapping(
             original,
             () -> {
                 //create the changed version on-the-fly, right here.
             },
             true|false
         );
     
    Since:
    4.1.0
    Version:
    $Id: 6bd6766e8f3b6b1d1493457c9e082853aa3135f9 $
    Author:
    Mihai Andronache (amihaiemil@gmail.com)
    • Constructor Detail

      • MergedYamlMapping

        public MergedYamlMapping​(YamlMapping original,
                                 YamlMapping changed)
        Constructor. By default, conflicting keys will not be overriden.
        Parameters:
        original - YamlMapping in which the changes will be merged.
        changed - YamlMapping containing the differences.
      • MergedYamlMapping

        public MergedYamlMapping​(YamlMapping original,
                                 Supplier<YamlMapping> changed)
        Constructor. By default, conflicting keys will not be overriden.
        Parameters:
        original - YamlMapping in which the changes will be merged.
        changed - Supplier of YamlMapping containing the differences.
      • MergedYamlMapping

        public MergedYamlMapping​(YamlMapping original,
                                 Supplier<YamlMapping> changed,
                                 boolean overrideConflicts)
        Constructor. You can choose whether conflicting keys will be overriden or not.
        Parameters:
        original - YamlMapping in which the changes will be merged.
        changed - YamlMapping containing the differences.
        overrideConflicts - Override key conflicts or not?
      • MergedYamlMapping

        public MergedYamlMapping​(YamlMapping original,
                                 YamlMapping changed,
                                 boolean overrideConflicts)
        Constructor. You can choose whether conflicting keys will be overriden or not.
        Parameters:
        original - YamlMapping in which the changes will be merged.
        changed - YamlMapping containing the differences.
        overrideConflicts - Override key conflicts or not?