Interface StatefulSession
- All Superinterfaces:
AutoCloseable,Environment,EvaluationListeners,EvaluatorsContext,FluentEnvironment<StatefulSession>,FluentImports<StatefulSession>,RuleSession<StatefulSession>,RuleSet<RuntimeRule>,RuleSetContext<StatefulSession,,RuntimeRule> RuntimeContext<StatefulSession>
-
Field Summary
Fields inherited from interface org.evrete.api.RuntimeContext
SALIENCE_COMPARATOR -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()This method clears session's working memory and its beta-memory nodes as if the session had never been used.voidclose()Closes the session and destroys its memory.delete(FactHandle handle) Deletes a fact from working memory.fire()Fire all rules.default Future<StatefulSession> Same asfireAsync(Object), with the Future's get method will returning the session itself.<T> Future<T> fireAsync(T result) Fires session asynchronously and returns a Future representing the session execution status.default <T> StatefulSessionforEachFact(Class<T> type, Consumer<T> consumer) A memory inspection method that accepts fact type as an argument.default <T> StatefulSessionforEachFact(Class<T> type, Predicate<T> filter, Consumer<T> consumer) A filtering version of theforEachFact(Class, Consumer)method.<T> StatefulSessionforEachFact(String type, Consumer<T> consumer) A memory inspection method that accepts fact type as an argument.default <T> StatefulSessionforEachFact(String type, Predicate<T> filter, Consumer<T> consumer) A filtering version of theforEachFact(String, Consumer)method.forEachFact(BiConsumer<FactHandle, Object> consumer) A full-scan memory inspection method.default StatefulSessionforEachFact(BiPredicate<FactHandle, Object> filter, BiConsumer<FactHandle, Object> consumer) default StatefulSessionforEachFact(Consumer<Object> consumer) <T> TgetFact(FactHandle handle) Returns fact by its handle.default StatefulSessioninsertAndFire(Iterable<?> objects) default StatefulSessioninsertAndFire(Object... objects) update(FactHandle handle, Object newValue) Updates a fact that already exists in the working memoryMethods inherited from interface org.evrete.api.Environment
get, get, getPropertyNamesMethods inherited from interface org.evrete.api.EvaluationListeners
addListener, removeListenerMethods inherited from interface org.evrete.api.EvaluatorsContext
addEvaluator, addEvaluator, getEvaluator, replaceEvaluator, replaceEvaluatorMethods inherited from interface org.evrete.api.FluentEnvironment
setMethods inherited from interface org.evrete.api.FluentImports
addImport, addImport, getImports, getJavaImportsMethods inherited from interface org.evrete.api.RuleSession
addEventListener, asCollector, getActivationManager, getParentContext, insert, insert, insert, insert0, insert0, insertAs, insertAs, insertAs, removeEventListener, setActivationManager, setExecutionPredicateMethods inherited from interface org.evrete.api.RuleSet
addRule, compileRule, getRule, getRule, getRules, resolveFieldReferences, ruleExists, setRuleBuilderExceptionHandlerMethods inherited from interface org.evrete.api.RuntimeContext
compile, compile, getActivationManagerFactory, getClassLoader, getConfiguration, getExpressionResolver, getRuleComparator, getService, getSourceCompiler, getTypeResolver, newRule, newRule, setActivationManagerFactory, setActivationManagerFactory, setActivationMode, setClassLoader, setRuleComparator, wrapTypeResolver
-
Method Details
-
fire
StatefulSession fire()Fire all rules.- Specified by:
firein interfaceRuleSession<StatefulSession>
-
update
Updates a fact that already exists in the working memory
- Parameters:
handle- fact handle, previously assigned to original factnewValue- an updated version of the fact
-
delete
Deletes a fact from working memory.
- Parameters:
handle- fact handle
-
getFact
Returns fact by its handle.
- Type Parameters:
T- type of the fact (useObjector wildcard if type is unknown)- Parameters:
handle- fact handle- Returns:
- fact or
nullif fact is not found
-
fireAsync
Fires session asynchronously and returns a Future representing the session execution status.
- Type Parameters:
T- result type parameter- Parameters:
result- the result to return by the Future- Returns:
- a Future representing pending completion of the
fire()command - Throws:
RejectedExecutionException- if the task cannot be scheduled for execution
-
fireAsync
Same as
fireAsync(Object), with the Future's get method will returning the session itself.- Returns:
- a Future representing pending completion of the
fire()command. - Throws:
RejectedExecutionException- if the task cannot be scheduled for execution- See Also:
-
close
void close()Closes the session and destroys its memory. A closed session can not be reused.
- Specified by:
closein interfaceAutoCloseable
-
clear
void clear()This method clears session's working memory and its beta-memory nodes as if the session had never been used.
-
forEachFact
A full-scan memory inspection method.
- Parameters:
consumer- consumer for the facts
-
forEachFact
default StatefulSession forEachFact(BiPredicate<FactHandle, Object> filter, BiConsumer<FactHandle, Object> consumer) -
forEachFact
-
forEachFact
A memory inspection method that accepts fact type as an argument.
- Type Parameters:
T- expected java type for the provided type name- Parameters:
type- expected fact typeconsumer- consumer for the facts- Throws:
ClassCastException- if a working memory object can not be cast to the specified typeIllegalArgumentException- if no such type exists- See Also:
-
forEachFact
A memory inspection method that accepts fact type as an argument. Type name can be either a class name or a name of explicitly declared type. In the latter case, the generic type parameter
Tmust match the declared type's Java type (seeType.getJavaType())- Type Parameters:
T- expected java type for the provided type name- Parameters:
type- type nameconsumer- consumer for the facts- Throws:
ClassCastException- if a working memory object can not be cast to the specified typeIllegalArgumentException- if no such type exists- See Also:
-
forEachFact
A filtering version of the
forEachFact(Class, Consumer)method.- Type Parameters:
T- expected java type for the provided type name- Parameters:
type- expected fact typefilter- filtering predicateconsumer- consumer for the facts- See Also:
-
forEachFact
A filtering version of the
forEachFact(String, Consumer)method.- Type Parameters:
T- expected java type for the provided type name- Parameters:
type- expected fact typefilter- filtering predicateconsumer- consumer for the facts- See Also:
-
insertAndFire
-
insertAndFire
-