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: c07b9f7b3e47ab637021dbfcd2e3d14ad9162937 $
    Author:
    Mihai Andronache ([email protected])
    • 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?