Class BaseNode

java.lang.Object
org.drools.core.common.BaseNode
All Implemented Interfaces:
Serializable, NetworkNode
Direct Known Subclasses:
AbstractTerminalNode, LeftTupleSource, ObjectSource

public abstract class BaseNode extends Object implements NetworkNode
The base class for all Rete nodes.
See Also:
  • Field Details

    • id

      protected int id
    • memoryId

      protected int memoryId
    • partitionId

      protected RuleBasePartitionId partitionId
    • associations

      protected Set<Rule> associations
    • hashcode

      protected int hashcode
  • Constructor Details

    • BaseNode

      public BaseNode()
    • BaseNode

      public BaseNode(int id, RuleBasePartitionId partitionId)
      All nodes have a unique id, set in the constructor.
      Parameters:
      id - The unique id
  • Method Details

    • getId

      public int getId()
      Specified by:
      getId in interface NetworkNode
    • setId

      public void setId(int id)
    • getMemoryId

      public int getMemoryId()
    • initMemoryId

      protected void initMemoryId(BuildContext context)
    • isStreamMode

      public boolean isStreamMode()
    • setStreamMode

      protected void setStreamMode(boolean streamMode)
    • attach

      public void attach(BuildContext context)
      Attaches the node into the network. Usually to the parent ObjectSource or TupleSource
    • doAttach

      public void doAttach(BuildContext context)
    • networkUpdated

      public abstract void networkUpdated(UpdateContext updateContext)
      A method that is called for all nodes whose network below them changed, after the change is complete, providing them with an opportunity for state update
    • remove

      public boolean remove(RuleRemovalContext context, ReteooBuilder builder)
    • doRemove

      protected abstract boolean doRemove(RuleRemovalContext context, ReteooBuilder builder)
      Removes the node from the network. Usually from the parent ObjectSource or TupleSource
    • isInUse

      public abstract boolean isInUse()
      Returns true in case the current node is in use (is referenced by any other node)
    • getObjectTypeNode

      public abstract ObjectTypeNode getObjectTypeNode()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getPartitionId

      public RuleBasePartitionId getPartitionId()
      Returns the partition ID for which this node belongs to
      Specified by:
      getPartitionId in interface NetworkNode
    • setPartitionId

      public void setPartitionId(BuildContext context, RuleBasePartitionId partitionId)
      Sets the partition this node belongs to
    • addAssociation

      public void addAssociation(Rule rule)
      Associates this node with the give rule
    • addAssociation

      public void addAssociation(BuildContext context, Rule rule)
    • removeAssociation

      public boolean removeAssociation(Rule rule, RuleRemovalContext context)
      Removes the association to the given rule from the associations map.
    • getAssociationsSize

      public int getAssociationsSize()
    • getAssociatedRules

      public Rule[] getAssociatedRules()
      Specified by:
      getAssociatedRules in interface NetworkNode
    • isAssociatedWith

      public boolean isAssociatedWith(Rule rule)
      Specified by:
      isAssociatedWith in interface NetworkNode
    • addAssociatedTerminal

      public void addAssociatedTerminal(BaseTerminalNode terminalNode)
      Specified by:
      addAssociatedTerminal in interface NetworkNode
    • removeAssociatedTerminal

      public void removeAssociatedTerminal(BaseTerminalNode terminalNode)
      Specified by:
      removeAssociatedTerminal in interface NetworkNode
    • getAssociatedTerminalsSize

      public int getAssociatedTerminalsSize()
      Specified by:
      getAssociatedTerminalsSize in interface NetworkNode
    • hasAssociatedTerminal

      public boolean hasAssociatedTerminal(BaseTerminalNode terminalNode)
      Specified by:
      hasAssociatedTerminal in interface NetworkNode
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • getSinks

      public NetworkNode[] getSinks()
      Specified by:
      getSinks in interface NetworkNode