Package org.drools.core.common
Class BaseNode
- java.lang.Object
-
- org.drools.core.common.BaseNode
-
- All Implemented Interfaces:
NetworkNode
- Direct Known Subclasses:
AbstractTerminalNode,LeftTupleSource,ObjectSource
public abstract class BaseNode extends Object implements NetworkNode
The base class for all Rete nodes.
-
-
Field Summary
Fields Modifier and Type Field Description protected Bag<org.kie.api.definition.rule.Rule>associationsprotected inthashcodeprotected intidprotected intmemoryIdprotected RuleBasePartitionIdpartitionIdprotected booleanpartitionsEnabled
-
Constructor Summary
Constructors Constructor Description BaseNode()BaseNode(int id, RuleBasePartitionId partitionId, boolean partitionsEnabled)All nodes have a unique id, set in the constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAssociation(BuildContext context, org.kie.api.definition.rule.Rule rule)voidaddAssociation(org.kie.api.definition.rule.Rule rule)Associates this node with the give rulevoidattach(BuildContext context)Attaches the node into the network.voiddoAttach(BuildContext context)protected abstract booleandoRemove(RuleRemovalContext context, ReteooBuilder builder)Removes the node from the network.org.kie.api.definition.rule.Rule[]getAssociatedRules()intgetAssociatedRuleSize()Returns the number of rules that are associated with this node, regardless of how many times the node is associated with a single rule.intgetAssociationsSize()Returns how many times this nodes has been associated.intgetAssociationsSize(org.kie.api.definition.rule.Rule rule)intgetId()Returns the unique id that represents the node in the Rete networkintgetMemoryId()abstract ObjectTypeNodegetObjectTypeNode()RuleBasePartitionIdgetPartitionId()Returns the partition ID for which this node belongs toSink[]getSinks()inthashCode()protected voidinitMemoryId(BuildContext context)booleanisAssociatedWith(org.kie.api.definition.rule.Rule rule)abstract booleanisInUse()Returns true in case the current node is in use (is referenced by any other node)booleanisStreamMode()abstract voidnetworkUpdated(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 updatebooleanremove(RuleRemovalContext context, ReteooBuilder builder)booleanremoveAssociation(org.kie.api.definition.rule.Rule rule)Removes the association to the given rule from the associations map.voidsetId(int id)voidsetPartitionId(BuildContext context, RuleBasePartitionId partitionId)Sets the partition this node belongs tovoidsetPartitionsEnabled(boolean partitionsEnabled)protected voidsetStreamMode(boolean streamMode)StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.drools.core.common.NetworkNode
getType
-
-
-
-
Field Detail
-
id
protected int id
-
memoryId
protected int memoryId
-
partitionId
protected RuleBasePartitionId partitionId
-
partitionsEnabled
protected boolean partitionsEnabled
-
associations
protected Bag<org.kie.api.definition.rule.Rule> associations
-
hashcode
protected int hashcode
-
-
Constructor Detail
-
BaseNode
public BaseNode()
-
BaseNode
public BaseNode(int id, RuleBasePartitionId partitionId, boolean partitionsEnabled)All nodes have a unique id, set in the constructor.- Parameters:
id- The unique id
-
-
Method Detail
-
getId
public int getId()
Description copied from interface:NetworkNodeReturns the unique id that represents the node in the Rete network- Specified by:
getIdin interfaceNetworkNode
-
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 parentObjectSourceorTupleSource
-
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 parentObjectSourceorTupleSource
-
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()
-
getPartitionId
public RuleBasePartitionId getPartitionId()
Returns the partition ID for which this node belongs to- Specified by:
getPartitionIdin interfaceNetworkNode
-
setPartitionId
public void setPartitionId(BuildContext context, RuleBasePartitionId partitionId)
Sets the partition this node belongs to
-
setPartitionsEnabled
public void setPartitionsEnabled(boolean partitionsEnabled)
-
addAssociation
public void addAssociation(org.kie.api.definition.rule.Rule rule)
Associates this node with the give rule
-
addAssociation
public void addAssociation(BuildContext context, org.kie.api.definition.rule.Rule rule)
-
removeAssociation
public boolean removeAssociation(org.kie.api.definition.rule.Rule rule)
Removes the association to the given rule from the associations map.
-
getAssociationsSize
public int getAssociationsSize()
Description copied from interface:NetworkNodeReturns how many times this nodes has been associated. Note that due to subnetworks this node could be associated to the same rule multiple times.- Specified by:
getAssociationsSizein interfaceNetworkNode
-
getAssociatedRules
public org.kie.api.definition.rule.Rule[] getAssociatedRules()
- Specified by:
getAssociatedRulesin interfaceNetworkNode
-
getAssociatedRuleSize
public int getAssociatedRuleSize()
Description copied from interface:NetworkNodeReturns the number of rules that are associated with this node, regardless of how many times the node is associated with a single rule.- Specified by:
getAssociatedRuleSizein interfaceNetworkNode
-
getAssociationsSize
public int getAssociationsSize(org.kie.api.definition.rule.Rule rule)
- Specified by:
getAssociationsSizein interfaceNetworkNode
-
isAssociatedWith
public boolean isAssociatedWith(org.kie.api.definition.rule.Rule rule)
- Specified by:
isAssociatedWithin interfaceNetworkNode
-
getSinks
public Sink[] getSinks()
-
-