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

public class OptimizeTreeStructure extends TreeTransformer
Cleans up a loaded Tree by merging non-wildcard siblings into an existing wildcard node, adding a synthetic value field under childless wildcard nodes, and marking JSON array elements as record breaks.
  • Constructor Details

    • OptimizeTreeStructure

      public OptimizeTreeStructure()
  • Method Details

    • 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
    • mergeWildcardSiblings

      protected void mergeWildcardSiblings(TreeNode parent)
      Merges every other child of the parent into its first wildcard child, if it has one.
    • ensureSoloDescendantsAreNotRecordBreaks

      protected void ensureSoloDescendantsAreNotRecordBreaks(TreeNode parent)
      Clears the record-break flag of each only child below the parent, recursively; not called by transform(Tree).
    • addSingleValueWildcardChildField

      protected void addSingleValueWildcardChildField(TreeNode parent)
      Gives a childless, non-array wildcard node a child field, suffixed _value, that reads the node's text.
    • addRecordBreakOnArray

      protected void addRecordBreakOnArray(TreeNode child)
      Marks the node as a record break if its parent is a JSON array.