java.lang.Object
com.northconcepts.datapipeline.foundations.pipeline.tree.detect.TreeTransformer
com.northconcepts.datapipeline.foundations.pipeline.tree.detect.CollapseSiblingPatterns

public class CollapseSiblingPatterns extends TreeTransformer
Collapses down (merges) sibling tree-node-paths whose names share a derivable naming/wildcard pattern (see SiblingSetRule) into a single wildcard node, mirroring what the build-time NodeNameRules produce for individually dynamic names: the collapsed node is named *, its XPath expression ends in node(), member names become its values, and descendant XPaths collapse the merged segment to *.

Opt-in — insert it before the detection passes with TreeDetectionStrategy.enableSiblingPatternCollapse(), ideally together with standard(true) so wildcard post-processing (leftover-sibling merging and synthetic value fields for childless nodes) applies to the collapsed node too. One pattern is collapsed per parent: rules are consulted in order and the first rule to derive a pattern wins, so rule order sets precedence (within AffixSiblingSetRule, competing name buckets are tried largest first).

  • Constructor Details

    • CollapseSiblingPatterns

      public CollapseSiblingPatterns()
      Creates a pass with a single AffixSiblingSetRule.
  • Method Details

    • getRules

      public List<SiblingSetRule> getRules()
      Returns the editable list of rules, consulted in order; the first one to derive a pattern wins.
    • addRule

      public CollapseSiblingPatterns addRule(SiblingSetRule rule)
      Adds a rule, consulted after the existing ones.
    • clearRules

      public CollapseSiblingPatterns clearRules()
      Removes all rules, including the default AffixSiblingSetRule.
    • transform

      public void transform(Tree tree)
      Description copied from class: TreeTransformer
      Runs this pass over the loaded tree, updating its nodes in place.
      Specified by:
      transform in class TreeTransformer
    • collapseChildren

      protected void collapseChildren(TreeNode parent)
      Merges the parent's children that match the first pattern a rule derives into one wildcard node; called for every node, children before parents.
    • getCandidateSiblings

      protected List<TreeNode> getCandidateSiblings(TreeNode parent)
      Returns the children eligible for pattern derivation: named element/field nodes, excluding attributes, existing wildcards, JSON container nodes, and nodes without an XPath expression.