Class AbstractRuleChainVisitor

  • All Implemented Interfaces:

    public abstract class AbstractRuleChainVisitor
    extends Object
    implements RuleChainVisitor
    This is a base class for RuleChainVisitor implementations which extracts interesting nodes from an AST, and lets each Rule visit the nodes it has expressed interest in.
    • Field Detail

      • ruleSetRules

        protected Map<RuleSet,​List<Rule>> ruleSetRules
        These are all the rules participating in the RuleChain, grouped by RuleSet.
      • nodeNameToNodes

        protected Map<String,​List<Node>> nodeNameToNodes
        This is a mapping from node names to nodes instances for the current AST.
    • Constructor Detail

      • AbstractRuleChainVisitor

        public AbstractRuleChainVisitor()
    • Method Detail

      • visit

        protected abstract void visit​(Rule rule,
                                      Node node,
                                      RuleContext ctx)
        Visit the given rule to the given node.
      • indexNodes

        protected abstract void indexNodes​(List<Node> nodes,
                                           RuleContext ctx)
        Index all nodes for visitation by rules.
      • indexNode

        protected void indexNode​(Node node)
        Index a single node for visitation by rules.
      • initialize

        protected void initialize()
        Initialize the RuleChainVisitor to be ready to perform visitations. This method should not be called until it is known that all Rules participating in the RuleChain are ready to be initialized themselves. Some rules may require full initialization to determine if they will participate in the RuleChain, so this has been delayed as long as possible to ensure that manipulation of the Rules is no longer occurring.
      • clear

        protected void clear()
        Clears the internal data structure used to manage the nodes visited between visiting different ASTs.