Package org.kie.api.runtime.rule
Interface AccumulateFunction<C extends java.io.Serializable>
-
- All Superinterfaces:
java.io.Externalizable,java.io.Serializable
public interface AccumulateFunction<C extends java.io.Serializable> extends java.io.ExternalizableAn interface for accumulate external function implementations
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaccumulate(C context, java.lang.Object value)Executes the accumulation actiondefault java.lang.ObjectaccumulateValue(C context, java.lang.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.CcreateContext()Creates and returns a new context objectjava.lang.ObjectgetResult(C context)java.lang.Class<?>getResultType()voidinit(C context)Initializes the accumulatordefault CinitContext(C context)Initializes the accumulator, possibly returning a new accumulation context instead of the original onevoidreverse(C context, java.lang.Object value)Reverses the accumulation actionbooleansupportsReverse()default booleantryReverse(C context, java.lang.Object value)Reverses the accumulation action
-
-
-
Method Detail
-
createContext
C createContext()
Creates and returns a new context object- Returns:
- new context object
-
init
void init(C context) throws java.lang.Exception
Initializes the accumulator- Parameters:
context- never null- Throws:
java.lang.Exception
-
initContext
default C initContext(C context)
Initializes the accumulator, possibly returning a new accumulation context instead of the original one- Parameters:
context-- Returns:
- new context object
-
accumulate
void accumulate(C context, java.lang.Object value)
Executes the accumulation action- Parameters:
context- never nullvalue-
-
accumulateValue
default java.lang.Object accumulateValue(C context, java.lang.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.- Parameters:
context-value-- Returns:
- the accumulated object
-
reverse
void reverse(C context, java.lang.Object value) throws java.lang.Exception
Reverses the accumulation action- Parameters:
context- never nullvalue-- Throws:
java.lang.Exception
-
getResult
java.lang.Object getResult(C context) throws java.lang.Exception
- Returns:
- the current value in this accumulation session
- Throws:
java.lang.Exception
-
supportsReverse
boolean supportsReverse()
- Returns:
- true if the function supports reverse, otherwise false
-
getResultType
java.lang.Class<?> getResultType()
- Returns:
- the class type of the result of this function
-
tryReverse
default boolean tryReverse(C context, java.lang.Object value)
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.
-
-