Package org.drools.core.rule
Class Accumulate
- java.lang.Object
-
- org.drools.core.rule.ConditionalElement
-
- org.drools.core.rule.Accumulate
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Cloneable
,PatternSource
,RuleConditionElement
,RuleComponent
- Direct Known Subclasses:
MultiAccumulate
,SingleAccumulate
public abstract class Accumulate extends ConditionalElement implements PatternSource
A class to represent the Accumulate CE- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Accumulate>
cloned
protected Declaration[]
innerDeclarationCache
protected Declaration[]
requiredDeclarations
protected RuleConditionElement
source
-
Constructor Summary
Constructors Constructor Description Accumulate()
Accumulate(RuleConditionElement source, Declaration[] requiredDeclarations)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Object
accumulate(Object workingMemoryContext, Object context, Tuple match, InternalFactHandle handle, WorkingMemory workingMemory)
Executes the accumulate (action) code for the given fact handleabstract Object
accumulate(Object workingMemoryContext, Tuple match, InternalFactHandle childHandle, AccumulateNode.GroupByContext groupByContext, TupleList<AccumulateNode.AccumulateContextEntry> tupleList, WorkingMemory wm)
abstract Accumulate
clone()
Returns a clone from itselfabstract Object
createFunctionContext()
abstract Object
createWorkingMemoryContext()
abstract Accumulator[]
getAccumulators()
protected Declaration[]
getInnerDeclarationCache()
Map<String,Declaration>
getInnerDeclarations()
Returns a Map of declarations that are visible inside this conditional elementList<RuleConditionElement>
getNestedElements()
Returs a list of RuleConditionElement's that are nested inside the current elementMap<String,Declaration>
getOuterDeclarations()
Returns a Map of declarations that are visible outside this conditional element.Declaration[]
getRequiredDeclarations()
abstract Object
getResult(Object workingMemoryContext, Object context, Tuple leftTuple, WorkingMemory workingMemory)
Gets the result of the accumulationRuleConditionElement
getSource()
boolean
hasRequiredDeclarations()
abstract Object
init(Object workingMemoryContext, Object accContext, Object funcContext, Tuple leftTuple, WorkingMemory workingMemory)
Executes the initialization block of codeboolean
isGroupBy()
abstract boolean
isMultiFunction()
boolean
isPatternScopeDelimiter()
Returns true in case this RuleConditionElement delimits a pattern visibility scope.void
readExternal(ObjectInput in)
protected void
registerClone(Accumulate clone)
abstract void
replaceAccumulatorDeclaration(Declaration declaration, Declaration resolved)
void
replaceDeclaration(Declaration declaration, Declaration resolved)
boolean
requiresLeftActivation()
Declaration
resolveDeclaration(String identifier)
Resolves the given identifier in the current scope and returns the Declaration object for the declaration.abstract boolean
supportsReverse()
Returns true if this accumulate supports reverseabstract boolean
tryReverse(Object workingMemoryContext, Object context, Tuple leftTuple, InternalFactHandle handle, RightTuple rightParent, LeftTuple match, WorkingMemory workingMemory)
Executes the reverse (action) code for the given fact handlevoid
writeExternal(ObjectOutput out)
-
-
-
Field Detail
-
source
protected RuleConditionElement source
-
requiredDeclarations
protected Declaration[] requiredDeclarations
-
innerDeclarationCache
protected Declaration[] innerDeclarationCache
-
cloned
protected List<Accumulate> cloned
-
-
Constructor Detail
-
Accumulate
public Accumulate()
-
Accumulate
public Accumulate(RuleConditionElement source, Declaration[] requiredDeclarations)
-
-
Method Detail
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
getAccumulators
public abstract Accumulator[] getAccumulators()
-
createFunctionContext
public abstract Object createFunctionContext()
-
init
public abstract Object init(Object workingMemoryContext, Object accContext, Object funcContext, Tuple leftTuple, WorkingMemory workingMemory)
Executes the initialization block of code
-
accumulate
public abstract Object accumulate(Object workingMemoryContext, Object context, Tuple match, InternalFactHandle handle, WorkingMemory workingMemory)
Executes the accumulate (action) code for the given fact handle
-
tryReverse
public abstract boolean tryReverse(Object workingMemoryContext, Object context, Tuple leftTuple, InternalFactHandle handle, RightTuple rightParent, LeftTuple match, WorkingMemory workingMemory)
Executes the reverse (action) code for the given fact handle
-
getResult
public abstract Object getResult(Object workingMemoryContext, Object context, Tuple leftTuple, WorkingMemory workingMemory)
Gets the result of the accumulation
-
supportsReverse
public abstract boolean supportsReverse()
Returns true if this accumulate supports reverse
-
clone
public abstract Accumulate clone()
Description copied from interface:RuleConditionElement
Returns a clone from itself- Specified by:
clone
in interfaceRuleConditionElement
- Specified by:
clone
in classConditionalElement
- Returns:
-
registerClone
protected void registerClone(Accumulate clone)
-
getSource
public RuleConditionElement getSource()
-
getInnerDeclarations
public Map<String,Declaration> getInnerDeclarations()
Description copied from interface:RuleConditionElement
Returns a Map of declarations that are visible inside this conditional element- Specified by:
getInnerDeclarations
in interfaceRuleConditionElement
- Returns:
-
getOuterDeclarations
public Map<String,Declaration> getOuterDeclarations()
Description copied from interface:RuleConditionElement
Returns a Map of declarations that are visible outside this conditional element.- Specified by:
getOuterDeclarations
in interfaceRuleConditionElement
- Returns:
-
resolveDeclaration
public Declaration resolveDeclaration(String identifier)
Description copied from interface:RuleConditionElement
Resolves the given identifier in the current scope and returns the Declaration object for the declaration. Returns null if identifier can not be resolved.- Specified by:
resolveDeclaration
in interfaceRuleConditionElement
- Returns:
-
createWorkingMemoryContext
public abstract Object createWorkingMemoryContext()
-
getNestedElements
public List<RuleConditionElement> getNestedElements()
Description copied from interface:RuleConditionElement
Returs a list of RuleConditionElement's that are nested inside the current element- Specified by:
getNestedElements
in interfaceRuleConditionElement
- Returns:
-
isPatternScopeDelimiter
public boolean isPatternScopeDelimiter()
Description copied from interface:RuleConditionElement
Returns true in case this RuleConditionElement delimits a pattern visibility scope. For instance, AND CE is not a scope delimiter, while NOT CE is a scope delimiter- Specified by:
isPatternScopeDelimiter
in interfaceRuleConditionElement
- Returns:
-
isMultiFunction
public abstract boolean isMultiFunction()
-
replaceDeclaration
public void replaceDeclaration(Declaration declaration, Declaration resolved)
-
replaceAccumulatorDeclaration
public abstract void replaceAccumulatorDeclaration(Declaration declaration, Declaration resolved)
-
getInnerDeclarationCache
protected Declaration[] getInnerDeclarationCache()
-
getRequiredDeclarations
public Declaration[] getRequiredDeclarations()
-
hasRequiredDeclarations
public boolean hasRequiredDeclarations()
-
requiresLeftActivation
public boolean requiresLeftActivation()
- Specified by:
requiresLeftActivation
in interfacePatternSource
-
isGroupBy
public boolean isGroupBy()
-
accumulate
public abstract Object accumulate(Object workingMemoryContext, Tuple match, InternalFactHandle childHandle, AccumulateNode.GroupByContext groupByContext, TupleList<AccumulateNode.AccumulateContextEntry> tupleList, WorkingMemory wm)
-
-