public class Rule extends Object implements Externalizable, Wireable, Dialectable, org.kie.api.definition.rule.Rule
Rule
contains a set of Test
s and a
Consequence
.
The Test
s describe the circumstances that representrepresent
a match for this rule. The Consequence
gets fired when the
Conditions match.
Modifier and Type | Field and Description |
---|---|
protected String |
activationListener |
static String |
DEFAULT_CONSEQUENCE_NAME |
Constructor and Description |
---|
Rule() |
Rule(String name) |
Rule(String name,
String agendaGroup)
Construct a
Rule |
Rule(String name,
String pkg,
String agendaGroup)
Construct a
Rule |
Modifier and Type | Method and Description |
---|---|
void |
addMetaAttribute(String key,
Object value) |
void |
addNamedConsequence(String name,
Consequence consequence) |
void |
addPattern(RuleConditionElement element)
Add a pattern to the rule.
|
boolean |
equals(Object obj) |
String |
getActivationGroup() |
String |
getActivationListener() |
String |
getAgendaGroup() |
boolean |
getAutoFocus() |
String[] |
getCalendars() |
Consequence |
getConsequence()
Retrieve the
Consequence associated with this
Rule . |
ConsequenceMetaData |
getConsequenceMetaData() |
Calendar |
getDateEffective() |
Calendar |
getDateExpires() |
Declaration |
getDeclaration(String identifier)
Retrieve a parameter
Declaration by identifier. |
Map<String,Declaration> |
getDeclarations()
Retrieve the set of all root fact object parameter
Declarations . |
String |
getDialect() |
Enabled |
getEnabled() |
String |
getId() |
org.kie.api.definition.KieDefinition.KnowledgeType |
getKnowledgeType() |
GroupElement |
getLhs()
Retrieve the
List of Conditions for this
rule. |
int |
getLoadOrder() |
String |
getMetaAttribute(String identifier)
Deprecated.
|
Map<String,Object> |
getMetaAttributes()
Deprecated.
|
Map<String,Object> |
getMetaData() |
static List |
getMethodBytecode(Class cls,
String ruleClassName,
String packageName,
String methodName,
String resource) |
String |
getName()
Retrieve the name of this rule.
|
Consequence |
getNamedConsequence(String consequenceName) |
Map<String,Consequence> |
getNamedConsequences() |
String |
getNamespace() |
String |
getPackage() |
String |
getPackageName() |
Rule |
getParent() |
String[] |
getRequiredDeclarationsForConsequence(String consequenceName) |
org.kie.api.io.Resource |
getResource() |
String |
getRuleFlowGroup() |
Salience |
getSalience()
Retrieve the
Rule salience. |
int |
getSpecifity() |
Timer |
getTimer()
Returns the Timer semantics for a rule.
|
GroupElement[] |
getTransformedLhs(LogicTransformer transformer)
Uses the LogicTransformer to process the Rule patters - if no ORs are
used this will return an array of a single AND element.
|
int |
hashCode() |
boolean |
hasLogicalDependency()
This field is updated at runtime, when the first logical assertion is done.
|
boolean |
hasNamedConsequences() |
boolean |
isEager() |
boolean |
isEffective(Tuple tuple,
RuleTerminalNode rtn,
WorkingMemory workingMemory)
This returns true is the rule is effective.
|
boolean |
isEnabled(Tuple tuple,
RuleTerminalNode rtn,
WorkingMemory workingMemory) |
boolean |
isLockOnActive() |
boolean |
isNoLoop() |
boolean |
isQuery() |
boolean |
isSemanticallyValid()
This will return if the semantic actions or predicates in the rules
are valid.
|
boolean |
isValid()
Determine if this rule is internally consistent and valid.
|
Collection<String> |
listMetaAttributes()
Deprecated.
|
void |
readExternal(ObjectInput in) |
void |
setActivationGroup(String activationGroup) |
void |
setActivationListener(String activationListener) |
void |
setAgendaGroup(String agendaGroup) |
void |
setAutoFocus(boolean autoFocus) |
void |
setCalendars(String[] calendars) |
void |
setConsequence(Consequence consequence)
Set the
Consequence that is associated with the successful
match of this rule. |
void |
setDateEffective(Calendar effectiveDate)
Sets the date from which this rule takes effect (can include time to the millisecond).
|
void |
setDateExpires(Calendar expiresDate)
Sets the date after which the rule will no longer apply (can include time to the millisecond).
|
void |
setDialect(String dialect) |
void |
setEager(boolean eager) |
void |
setEnabled(Enabled b)
A rule is enabled by default.
|
void |
setHasLogicalDependency(boolean hasLogicalDependency) |
void |
setLhs(GroupElement lhsRoot) |
void |
setLoadOrder(int loadOrder) |
void |
setLockOnActive(boolean lockOnActive) |
void |
setNoLoop(boolean noLoop) |
void |
setPackage(String pkg) |
void |
setParent(Rule parent) |
void |
setRequiredDeclarationsForConsequence(String consequenceName,
String[] requiredDeclarations) |
void |
setResource(org.kie.api.io.Resource resource) |
void |
setRuleFlowGroup(String ruleFlowGroup) |
void |
setSalience(Salience salience)
Set the
Rule |
void |
setSemanticallyValid(boolean valid) |
void |
setTimer(Timer timer)
Sets the timer semantics for a rule.
|
String |
toString() |
void |
wire(Object object) |
void |
writeExternal(ObjectOutput out) |
public static final String DEFAULT_CONSEQUENCE_NAME
protected String activationListener
public Rule()
public Rule(String name, String pkg, String agendaGroup)
Rule with the given name for the specified pkg parent
name
- The name of this rule.public Rule(String name, String agendaGroup)
Rule with the given name for the specified pkg parent
name
- The name of this rule.public Rule(String name)
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public org.kie.api.io.Resource getResource()
public void setResource(org.kie.api.io.Resource resource)
public String getDialect()
getDialect
in interface Dialectable
public void setDialect(String dialect)
public Timer getTimer()
public void setTimer(Timer timer)
timer
- public boolean isValid()
A Rule
must include at least one parameter declaration and
one condition.
true
if this rule is valid, else
false
.public String getPackage()
public void setPackage(String pkg)
public String getPackageName()
getPackageName
in interface org.kie.api.definition.rule.Rule
public String getName()
getName
in interface org.kie.api.definition.rule.Rule
public Salience getSalience()
Rule
salience.public void setSalience(Salience salience)
Rule salience.
salience
- The salience.public String getAgendaGroup()
public void setAgendaGroup(String agendaGroup)
public boolean isNoLoop()
public boolean isEffective(Tuple tuple, RuleTerminalNode rtn, WorkingMemory workingMemory)
public void setNoLoop(boolean noLoop)
public boolean getAutoFocus()
public void setAutoFocus(boolean autoFocus)
public String getActivationGroup()
public void setActivationGroup(String activationGroup)
public String getRuleFlowGroup()
public void setRuleFlowGroup(String ruleFlowGroup)
public Declaration getDeclaration(String identifier)
Declaration
by identifier.identifier
- The identifier.null
if no declaration matches
the identifier
.public String[] getRequiredDeclarationsForConsequence(String consequenceName)
public void setRequiredDeclarationsForConsequence(String consequenceName, String[] requiredDeclarations)
public boolean hasLogicalDependency()
public void setHasLogicalDependency(boolean hasLogicalDependency)
public boolean isLockOnActive()
public void setLockOnActive(boolean lockOnActive)
public Map<String,Declaration> getDeclarations()
Declarations
.Declarations
in order which specify the
root fact objects.public void addPattern(RuleConditionElement element)
element
- The Test
to add.InvalidRuleException
public GroupElement getLhs()
List
of Conditions
for this
rule.List
of Conditions
.public void setLhs(GroupElement lhsRoot)
public GroupElement[] getTransformedLhs(LogicTransformer transformer) throws InvalidPatternException
InvalidPatternException
public int getSpecifity()
public void setConsequence(Consequence consequence)
Consequence
that is associated with the successful
match of this rule.consequence
- The Consequence
to attach to this
Rule
.public Consequence getConsequence()
Consequence
associated with this
Rule
.Consequence
.public boolean hasNamedConsequences()
public Map<String,Consequence> getNamedConsequences()
public Consequence getNamedConsequence(String consequenceName)
public void addNamedConsequence(String name, Consequence consequence)
public int getLoadOrder()
public void setLoadOrder(int loadOrder)
public boolean isEager()
public void setEager(boolean eager)
public void setSemanticallyValid(boolean valid)
public boolean isSemanticallyValid()
public String[] getCalendars()
public void setCalendars(String[] calendars)
public void setDateEffective(Calendar effectiveDate)
effectiveDate
- public void setDateExpires(Calendar expiresDate)
expiresDate
- public Calendar getDateEffective()
public Calendar getDateExpires()
public void setEnabled(Enabled b)
public Enabled getEnabled()
public boolean isEnabled(Tuple tuple, RuleTerminalNode rtn, WorkingMemory workingMemory)
public String getActivationListener()
public void setActivationListener(String activationListener)
public Map<String,Object> getMetaData()
getMetaData
in interface org.kie.api.definition.rule.Rule
@Deprecated public Map<String,Object> getMetaAttributes()
@Deprecated public String getMetaAttribute(String identifier)
@Deprecated public Collection<String> listMetaAttributes()
public void setParent(Rule parent)
public Rule getParent()
public static List getMethodBytecode(Class cls, String ruleClassName, String packageName, String methodName, String resource)
public boolean isQuery()
public org.kie.api.definition.KieDefinition.KnowledgeType getKnowledgeType()
getKnowledgeType
in interface org.kie.api.definition.KieDefinition
public String getNamespace()
getNamespace
in interface org.kie.api.definition.KieDefinition
public String getId()
getId
in interface org.kie.api.definition.KieDefinition
public ConsequenceMetaData getConsequenceMetaData()
Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.