Package org.jeasy.rules.core
Class BasicRule
java.lang.Object
org.jeasy.rules.core.BasicRule
- All Implemented Interfaces:
Comparable<Rule>,Rule
Basic rule implementation class that provides common methods.
You can extend this class and override evaluate(Facts) and execute(Facts) to provide rule conditions and actions logic.
- Author:
- Mahmoud Ben Hassine ([email protected])
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringRule description.protected StringRule name.protected intRule priority.Fields inherited from interface org.jeasy.rules.api.Rule
DEFAULT_DESCRIPTION, DEFAULT_NAME, DEFAULT_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanbooleanThis method implements the rule's condition(s).voidThis method implements the rule's action(s).Getter for rule description.getName()Getter for rule name.intGetter for rule priority.inthashCode()voidsetDescription(String description) voidsetPriority(int priority) toString()
-
Field Details
-
name
Rule name. -
description
Rule description. -
priority
protected int priorityRule priority.
-
-
Constructor Details
-
BasicRule
Deprecated, for removal: This API element is subject to removal in a future version.To avoid hardcoded rule name, Rule name should be uniqueCreate a newBasicRule. Please use other constructor method as name parameter uniquely identifies a rule -
BasicRule
Create a newBasicRule.- Parameters:
name- rule name
-
BasicRule
Create a newBasicRule.- Parameters:
name- rule namedescription- rule description
-
BasicRule
Create a newBasicRule.- Parameters:
name- rule namedescription- rule descriptionpriority- rule priority
-
-
Method Details
-
evaluate
This method implements the rule's condition(s). Implementations should handle any runtime exception and return true/false accordingly -
execute
This method implements the rule's action(s). -
getName
Description copied from interface:RuleGetter for rule name. -
getDescription
Description copied from interface:RuleGetter for rule description.- Specified by:
getDescriptionin interfaceRule- Returns:
- rule description
-
setDescription
-
getPriority
public int getPriority()Description copied from interface:RuleGetter for rule priority.- Specified by:
getPriorityin interfaceRule- Returns:
- rule priority
-
setPriority
public void setPriority(int priority) -
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<Rule>
-