Package org.jeasy.rules.api
Class Rules
java.lang.Object
org.jeasy.rules.api.Rules
This class encapsulates a set of rules and represents a rules namespace. Rules must have a unique
name within a rules namespace.
Rules will be compared to each other based on Comparable.compareTo(Object)
method, so Rule
's implementations are expected to correctly implement compareTo
to ensure unique
rule names within a single namespace.
- Author:
- Mahmoud Ben Hassine ([email protected])
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear rules.boolean
isEmpty()
Check if the rule set is empty.iterator()
Return an iterator on the rules set.void
Register one or more new rules.void
int
size()
Return how many rules are currently registered.void
unregister
(Object... rules) Unregister one or more rules.void
unregister
(String ruleName) Unregister a rule by name.void
unregister
(Rules... rules) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Method Details
-
register
Register one or more new rules.- Parameters:
rules
- to register, must not be null
-
register
-
unregister
-
unregister
Unregister one or more rules.- Parameters:
rules
- to unregister, must not be null
-
unregister
Unregister a rule by name.- Parameters:
ruleName
- name of the rule to unregister, must not be null
-
isEmpty
public boolean isEmpty()Check if the rule set is empty.- Returns:
- true if the rule set is empty, false otherwise
-
clear
public void clear()Clear rules. -
size
public int size()Return how many rules are currently registered.- Returns:
- the number of rules currently registered
-
iterator
Return an iterator on the rules set. It is not intended to remove rules using this iterator.
-