Class MergedYamlSequence

  • All Implemented Interfaces:
    YamlNode, YamlSequence, Comparable<YamlNode>, Iterable<YamlNode>

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

      • MergedYamlSequence

        public MergedYamlSequence​(YamlSequence original,
                                  YamlSequence changed)
        Constructor. By default, it's simply going to add the elements of changed to the ones of original.
        Parameters:
        original - YamlSequence in which the changes will be merged.
        changed - YamlSequence containing the differences.
      • MergedYamlSequence

        public MergedYamlSequence​(YamlSequence original,
                                  Supplier<YamlSequence> changed)
        Constructor. By default, it's simply going to add the elements of changed to the ones of original.
        Parameters:
        original - YamlSequence in which the changes will be merged.
        changed - Supplier of YamlSequence containing the differences.
      • MergedYamlSequence

        public MergedYamlSequence​(YamlSequence original,
                                  Supplier<YamlSequence> changed,
                                  boolean overrideIndices)
        Constructor. You can choose whether to override existing indices or not.
        Parameters:
        original - YamlSequence in which the changes will be merged.
        changed - YamlSequence containing the differences.
        overrideIndices - Override existing indices or not?
      • MergedYamlSequence

        public MergedYamlSequence​(YamlSequence original,
                                  YamlSequence changed,
                                  boolean overrideIndices)
        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.
        overrideIndices - Override existing indices or not?