Package org.jeasy.rules.api
Class Facts
java.lang.Object
org.jeasy.rules.api.Facts
This class encapsulates a set of facts and represents a facts namespace. Facts have unique names
within a
Facts
object.- Author:
- Mahmoud Ben Hassine ([email protected])
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> void
Add a fact, replacing any fact with the same name.asMap()
Return a copy of the facts as a map.void
clear()
Clear facts.<T> T
Get the value of a fact by its name.Fact<?>
Get a fact by name.iterator()
Return an iterator on the set of facts.<T> void
Add a fact, replacing any fact with the same name.void
Remove a fact by name.<T> void
Remove a fact.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Facts
public Facts()
-
-
Method Details
-
put
Add a fact, replacing any fact with the same name.- Parameters:
name
- of the fact to add, must not be nullvalue
- of the fact to add, must not be null
-
add
Add a fact, replacing any fact with the same name.- Parameters:
fact
- to add, must not be null
-
remove
Remove a fact by name.- Parameters:
factName
- name of the fact to remove, must not be null
-
remove
Remove a fact.- Parameters:
fact
- to remove, must not be null
-
get
Get the value of a fact by its name. This is a convenience method provided as a short version ofgetFact(factName).getValue()
.- Type Parameters:
T
- type of the fact's value- Parameters:
factName
- name of the fact, must not be null- Returns:
- the value of the fact having the given name, or null if there is no fact with the given name
-
getFact
Get a fact by name.- Parameters:
factName
- name of the fact, must not be null- Returns:
- the fact having the given name, or null if there is no fact with the given name
-
asMap
Return a copy of the facts as a map. It is not intended to manipulate facts outside of the rules engine (aka other than manipulating them through rules).- Returns:
- a copy of the current facts as a
HashMap
-
iterator
Return an iterator on the set of facts. It is not intended to remove facts using this iterator outside of the rules engine (aka other than doing it through rules) -
clear
public void clear()Clear facts. -
toString
-