java.lang.Object
software.amazon.smithy.rulesengine.logic.cfg.Cfg
All Implemented Interfaces:
Iterable<CfgNode>

public final class Cfg extends Object implements Iterable<CfgNode>
A Control Flow Graph (CFG) representation of endpoint rule decision logic.

The CFG transforms the hierarchical decision tree structure into an optimized representation with node deduplication to prevent exponential growth.

The CFG consists of:

  • A root node representing the entry point of the decision logic
  • A DAG structure where condition nodes are shared when they have identical subtrees
  • Method Details

    • from

      public static Cfg from(EndpointRuleSet ruleSet)
      Create a CFG from the given ruleset.
      Parameters:
      ruleSet - Rules to convert to CFG.
      Returns:
      the CFG result.
    • getVersion

      public RulesVersion getVersion()
      Get the endpoint ruleset version of the CFG.
      Returns:
      endpoint ruleset version.
    • getConditions

      public Condition[] getConditions()
      Gets all unique conditions in the CFG, in the order they were discovered.
      Returns:
      array of conditions
    • getConditionIndex

      public Integer getConditionIndex(Condition condition)
      Gets the index of a condition in the conditions array.
      Parameters:
      condition - the condition to look up
      Returns:
      the index, or null if not found
    • getConditionCount

      public int getConditionCount()
      Gets the number of unique conditions in the CFG.
      Returns:
      the condition count
    • getParameters

      public Parameters getParameters()
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getRoot

      public CfgNode getRoot()
      Returns the root node of the control flow graph.
      Returns:
      the root node
    • iterator

      public Iterator<CfgNode> iterator()
      Specified by:
      iterator in interface Iterable<CfgNode>