A rule consists principally of two key components: Conditions and Actions.
Conditions define under which circumstances the Actions should be executed.
This class serves as an coherent unit of Conditions and Actions and allows
other operations such as giving the Rule a name and specify wether other
users should be able to view and use the Rule or not.
See Also: Condition, Action author: Sebastian Nozzi.
Constructor Summary
public
Rule(String name) Instantiates a new Rule with the given name.
public
Rule() Instantiates a new Rule (with an empty name).
Method Summary
public boolean
equals(Object obj) Provides a better implementation than the default, comparing the fields and
then performing "equals" on the Conditions and Actions.
public boolean
evaluateConditions(RuleContext context) Evaluate Conditions from the internal List of Conditions.
The evaluation stops as soon as one Condition evaluates to false.
Parameters: context - the RuleContext used to perform the evaluation.
public void
executeActions(RuleContext context) Execute all Actions of the internal list of Actions.
Parameters: context - the RuleContext used to perform the evaluation.
isPublic() Checks if is the Rule is marked as public.
public static boolean
propertyEquals(Object thisProperty, Object otherProperty) Convenience static method to properly compare two properties of an object,
taking into account that any of them could be "null".
public void
run(RuleContext rtc) Runs the Rule for the given RuleContext.
Provides a better implementation than the default, comparing the fields and
then performing "equals" on the Conditions and Actions.
The included Conditions and Actions should also override "equals" and provide
a better implementation.
Parameters: obj - the obj true, if equals See Also:java.lang.Object.equals(java.lang.Object)
Evaluate Conditions from the internal List of Conditions.
The evaluation stops as soon as one Condition evaluates to false.
Parameters: context - the RuleContext used to perform the evaluation. It should havebeen populated with at least the target instance. true, if all Conditions evaluated to true.
Execute all Actions of the internal list of Actions.
Parameters: context - the RuleContext used to perform the evaluation. It should havebeen populated with at least the target instance.
Gets the creator user-id.
The user-id is used for security purposes (for example an user can only
edit/delete his/her own Rules in the system).
the creator user-id
Checks if is the Rule is marked as public.
Public Rules are usable (but not editable) by other users in the
AgentSystem.
true, if the Rule is public.
propertyEquals
public static boolean propertyEquals(Object thisProperty, Object otherProperty)(Code)
Convenience static method to properly compare two properties of an object,
taking into account that any of them could be "null".
It avoids potential NullPointerExceptions that can be caused by comparing properties
using "equals".
Parameters: thisProperty - one property Parameters: otherProperty - the other property true, if successful
Runs the Rule for the given RuleContext.
It does the same as calling "evaluateConditions" and if successfull calling
"executeActions".
Parameters: rtc - the rtc
Sets the creator user-id.
The user-id is used for security purposes (for example an user can only
edit/delete his/her own Rules in the system).
Parameters: user - the new creator user-id.
Marks the Rule as public.
Public Rules are usable (but not editable) by other users in the
AgentSystem.
Parameters: isPublic - true if the Rule is to be published for all.
If the Rule has a name, then it is used as String version, otherwise the
default implementation is used.
an user readable version, using the Rule's name, if available. See Also:java.lang.Object.toString