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 String
Rule description.protected String
Rule name.protected int
Rule priority.Fields inherited from interface org.jeasy.rules.api.Rule
DEFAULT_DESCRIPTION, DEFAULT_NAME, DEFAULT_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
boolean
This method implements the rule's condition(s).void
This method implements the rule's action(s).Getter for rule description.getName()
Getter for rule name.int
Getter for rule priority.int
hashCode()
void
setDescription
(String description) void
setPriority
(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:Rule
Getter for rule name. -
getDescription
Description copied from interface:Rule
Getter for rule description.- Specified by:
getDescription
in interfaceRule
- Returns:
- rule description
-
setDescription
-
getPriority
public int getPriority()Description copied from interface:Rule
Getter for rule priority.- Specified by:
getPriority
in interfaceRule
- Returns:
- rule priority
-
setPriority
public void setPriority(int priority) -
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Rule>
-