java.lang.Object
com.northconcepts.datapipeline.foundations.pipeline.tree.detect.AffixSiblingSetRule
All Implemented Interfaces:
SiblingSetRule

public class AffixSiblingSetRule extends Object implements SiblingSetRule
Derives a SiblingSetPattern from siblings sharing a fixed prefix/suffix around a varying dynamic segment — for example item-1, item-2, item-3 collapse to item-*.

Sibling names are first bucketed by their leading text up to the first separator run (-, _, ., space). Within each large-enough bucket, the longest common prefix and suffix are backed off to successively shorter separator (and letter-to-digit) boundaries — shortest first, favoring the most general pattern — until every middle segment is non-empty and classified as dynamic by a single segment rule (default: StandardNodeNameRule; add a DateTimeNodeNameRule to derive patterns like report-* from report-2024-01-15, report-2024-01-16). Patterns whose affixes are empty after trimming separators are rejected — entirely dynamic names are the build-time rules' job.

  • Field Details

    • DEFAULT_MINIMUM_SIBLINGS

      public static final int DEFAULT_MINIMUM_SIBLINGS
      See Also:
  • Constructor Details

    • AffixSiblingSetRule

      public AffixSiblingSetRule()
      Creates a rule that classifies middle segments with a StandardNodeNameRule.
  • Method Details

    • getMinimumSiblings

      public int getMinimumSiblings()
      Returns the minimum number of pattern-sharing siblings required to derive a pattern (default 3).
    • setMinimumSiblings

      public AffixSiblingSetRule setMinimumSiblings(int minimumSiblings)
      Sets the minimum number of pattern-sharing siblings required to derive a pattern (default 3, at least 2).
    • getSegmentRules

      public List<NodeNameRule> getSegmentRules()
      Returns the editable list of rules, tried in order, that classify the varying middle segment of sibling names.
    • addSegmentRule

      public AffixSiblingSetRule addSegmentRule(NodeNameRule segmentRule)
      Adds a rule for classifying middle segments; all the middle segments of a pattern must satisfy the same rule.
    • clearSegmentRules

      public AffixSiblingSetRule clearSegmentRules()
      Removes all segment rules, including the default StandardNodeNameRule.
    • derivePattern

      public SiblingSetPattern derivePattern(TreeNode parent, List<TreeNode> candidateSiblings)
      Description copied from interface: SiblingSetRule
      Returns the pattern shared by the candidate children of parent, or null; CollapseSiblingPatterns passes its named children, excluding attributes, wildcards and JSON containers.
      Specified by:
      derivePattern in interface SiblingSetRule