Interface RuleActionContext
-
- All Known Implementing Classes:
DefaultDroolsRuleActionContext
public interface RuleActionContextThis interface represents the context for actions applied during rule evaluation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CartRAOgetCartRao()Get cart RAOjava.lang.ObjectgetDelegate()Returns a rule engine specific context object.java.lang.StringgetMetaData(java.lang.String key)Returns the rule's meta-data for the given key (ornull).java.lang.ObjectgetParameter(java.lang.String parameterName)Returns parameter of the running rule by it name or null if not found.<T> TgetParameter(java.lang.String parameterName, java.lang.Class<T> type)Returns parameter of the running rule by it name and type or throwsIllegalArgumentExceptionotherwise.java.util.Map<java.lang.String,java.lang.Object>getParameters()Returns parameters of the running rule.RuleEngineResultRAOgetRuleEngineResultRao()Get rule engine result RAOjava.util.Map<java.lang.String,java.lang.Object>getRuleMetadata()get rule metadatajava.lang.StringgetRuleName()Get the name of the rulejava.util.Optional<java.lang.String>getRulesModuleName()Get the name of the rules module.<T> TgetValue(java.lang.Class<T> type)Returns the value for a specific type from the default variables container.<T> TgetValue(java.lang.Class<T> type, java.lang.String... path)Returns the value for a specific type and variables container.<T> java.util.Set<T>getValues(java.lang.Class<T> type)Returns the values for a specific type from the default variables container.<T> java.util.Set<T>getValues(java.lang.Class<T> type, java.lang.String... path)Returns the values for a specific type and variables container.voidhalt()Stops evaluation of following rulesvoidinsertFacts(java.lang.Object... facts)Insert the facts in an array to a contextvoidinsertFacts(java.util.Collection facts)Insert the facts in a collection to a contextvoidscheduleForUpdate(java.lang.Object... facts)schedules the given facts for an update.voidsetParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)Sets parameters to the running rulevoidupdateFacts(java.lang.Object... facts)Update the facts in a contextvoidupdateScheduledFacts()updates any previously scheduled facts (seescheduleForUpdate(Object...)
-
-
-
Method Detail
-
getMetaData
java.lang.String getMetaData(java.lang.String key)
Returns the rule's meta-data for the given key (ornull). CallstoString()on the meta-data object.- Parameters:
key-- Returns:
- the string representation of the meta-data (or null)
-
scheduleForUpdate
void scheduleForUpdate(java.lang.Object... facts)
schedules the given facts for an update. Note: The actual fact update is invoked viaupdateScheduledFacts()- Parameters:
facts- the facts to schedule for update
-
updateScheduledFacts
void updateScheduledFacts()
updates any previously scheduled facts (seescheduleForUpdate(Object...)
-
getValue
<T> T getValue(java.lang.Class<T> type)
Returns the value for a specific type from the default variables container. If more than one value is found, the first one is returned.- Parameters:
type- - the type- Returns:
- the value or null if no value is found for the given type
-
getValues
<T> java.util.Set<T> getValues(java.lang.Class<T> type)
Returns the values for a specific type from the default variables container.- Parameters:
type- - the type- Returns:
- the values or an empty set if no value is found for the given type
-
getValue
<T> T getValue(java.lang.Class<T> type, java.lang.String... path)Returns the value for a specific type and variables container. If more than one value is found, the first one is returned.- Parameters:
type- - the typepath- - the path for the variables container- Returns:
- the value or null if no value is found for the given type
-
getValues
<T> java.util.Set<T> getValues(java.lang.Class<T> type, java.lang.String... path)Returns the values for a specific type and variables container.- Parameters:
type- - the typepath- - the path for the variables container- Returns:
- the values or an empty set if no value is found for the given type
-
insertFacts
void insertFacts(java.lang.Object... facts)
Insert the facts in an array to a context- Parameters:
facts- - the array of facts
-
insertFacts
void insertFacts(java.util.Collection facts)
Insert the facts in a collection to a context- Parameters:
facts- - the collection of facts
-
updateFacts
void updateFacts(java.lang.Object... facts)
Update the facts in a context- Parameters:
facts- - the array of facts
-
getCartRao
CartRAO getCartRao()
Get cart RAO
-
getRuleEngineResultRao
RuleEngineResultRAO getRuleEngineResultRao()
Get rule engine result RAO
-
getRuleName
java.lang.String getRuleName()
Get the name of the rule
-
getRuleMetadata
java.util.Map<java.lang.String,java.lang.Object> getRuleMetadata()
get rule metadata
-
getDelegate
java.lang.Object getDelegate()
Returns a rule engine specific context object.
-
getRulesModuleName
java.util.Optional<java.lang.String> getRulesModuleName()
Get the name of the rules module.
-
getParameters
java.util.Map<java.lang.String,java.lang.Object> getParameters()
Returns parameters of the running rule.
-
getParameter
java.lang.Object getParameter(java.lang.String parameterName)
Returns parameter of the running rule by it name or null if not found.
-
getParameter
<T> T getParameter(java.lang.String parameterName, java.lang.Class<T> type)Returns parameter of the running rule by it name and type or throwsIllegalArgumentExceptionotherwise.
-
setParameters
void setParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
Sets parameters to the running rule- Parameters:
parameters- - map of named objects, creating the execution context for an action
-
halt
void halt()
Stops evaluation of following rules
-
-