Package org.jeasy.rules.api
Class Facts
- java.lang.Object
-
- org.jeasy.rules.api.Facts
-
-
Constructor Summary
Constructors Constructor Description Facts()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> void
add(Fact<T> fact)
Add a fact, replacing any fact with the same name.Map<String,Object>
asMap()
Return a copy of the facts as a map.void
clear()
Clear facts.<T> T
get(String factName)
Get the value of a fact by its name.Fact<?>
getFact(String factName)
Get a fact by name.Iterator<Fact<?>>
iterator()
Return an iterator on the set of facts.<T> void
put(String name, T value)
Add a fact, replacing any fact with the same name.void
remove(String factName)
Remove a fact by name.<T> void
remove(Fact<T> fact)
Remove a fact.String
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
-
-
-
-
Method Detail
-
put
public <T> void put(String name, T value)
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
public <T> void add(Fact<T> fact)
Add a fact, replacing any fact with the same name.- Parameters:
fact
- to add, must not be null
-
remove
public void remove(String factName)
Remove a fact by name.- Parameters:
factName
- name of the fact to remove, must not be null
-
remove
public <T> void remove(Fact<T> fact)
Remove a fact.- Parameters:
fact
- to remove, must not be null
-
get
public <T> T get(String factName)
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
public Fact<?> getFact(String factName)
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
public Map<String,Object> 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
public Iterator<Fact<?>> 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.
-
-