Package org.jeasy.rules.api
Class Rules
- java.lang.Object
-
- org.jeasy.rules.api.Rules
-
public class Rules extends Object implements Iterable<Rule>
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 onComparable.compareTo(Object)method, soRule's implementations are expected to correctly implementcompareToto ensure unique rule names within a single namespace.- Author:
- Mahmoud Ben Hassine ([email protected])
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear rules.booleanisEmpty()Check if the rule set is empty.Iterator<Rule>iterator()Return an iterator on the rules set.voidregister(Object... rules)Register one or more new rules.intsize()Return how many rules are currently registered.voidunregister(Object... rules)Unregister one or more rules.voidunregister(String ruleName)Unregister a rule by name.-
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
-
-
-
-
Method Detail
-
register
public void register(Object... rules)
Register one or more new rules.- Parameters:
rules- to register, must not be null
-
unregister
public void unregister(Object... rules)
Unregister one or more rules.- Parameters:
rules- to unregister, must not be null
-
unregister
public void unregister(String ruleName)
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
-
-