Package org.kie.api.runtime.rule
Interface AccumulateFunction<C extends Serializable>
- All Superinterfaces:
Externalizable,Serializable
An interface for accumulate external function implementations
-
Method Summary
Modifier and TypeMethodDescriptionvoidaccumulate(C context, Object value) Executes the accumulation actiondefault ObjectaccumulateValue(C context, Object value) Executes the accumulation action returning the accumulated object that will be passed back to the reverse method when this value will be eventually removed from acccumulation.Creates and returns a new context objectClass<?>voidInitializes the accumulatordefault CinitContext(C context) Initializes the accumulator, possibly returning a new accumulation context instead of the original onevoidReverses the accumulation actionbooleandefault booleantryReverse(C context, Object value) Reverses the accumulation actionMethods inherited from interface java.io.Externalizable
readExternal, writeExternal
-
Method Details
-
createContext
C createContext()Creates and returns a new context object- Returns:
- new context object
-
init
Initializes the accumulator- Parameters:
context- never null- Throws:
Exception
-
initContext
Initializes the accumulator, possibly returning a new accumulation context instead of the original one- Parameters:
context-- Returns:
- new context object
-
accumulate
Executes the accumulation action- Parameters:
context- never nullvalue-
-
accumulateValue
Executes the accumulation action returning the accumulated object that will be passed back to the reverse method when this value will be eventually removed from acccumulation.- Parameters:
context-value-- Returns:
- the accumulated object
-
reverse
Reverses the accumulation action- Parameters:
context- never nullvalue-- Throws:
Exception
-
getResult
- Returns:
- the current value in this accumulation session
- Throws:
Exception
-
supportsReverse
boolean supportsReverse()- Returns:
- true if the function supports reverse, otherwise false
-
getResultType
Class<?> getResultType()- Returns:
- the class type of the result of this function
-
tryReverse
Reverses the accumulation action- Parameters:
context-value-- Returns:
- true if this accumulate function was able to remove this value, false otherwise. In this last case the engine will have to retrigger a full reaccumulation.
-