Interface RuleSession<S extends RuleSession<S>>
-
- All Superinterfaces:
Environment,EvaluationListeners,EvaluatorsContext,FluentEnvironment<S>,FluentImports<S>,RuleSet<RuntimeRule>,RuleSetContext<S,RuntimeRule>,RuntimeContext<S>
- All Known Subinterfaces:
StatefulSession,StatelessSession
public interface RuleSession<S extends RuleSession<S>> extends RuleSetContext<S,RuntimeRule>
Base interface for both stateful and stateless sessions
-
-
Field Summary
-
Fields inherited from interface org.evrete.api.RuntimeContext
SALIENCE_COMPARATOR
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description SaddEventListener(SessionLifecycleListener listener)<T> Collector<T,?,S>asCollector()A convenience method that returns an instance ofCollectorfor inserting streams of facts.Objectfire()ActivationManagergetActivationManager()KnowledgegetParentContext()default Sinsert(Iterable<?> objects)Inserts a collection of facts.default FactHandleinsert(Object fact)Inserts a fact in working memory and returns a serializable fact handle.default Sinsert(Object... objects)Inserts an array of facts.FactHandleinsert0(Object fact, boolean resolveCollections)Inserts a fact in working memory and returns a serializable fact handle.FactHandleinsert0(String type, Object fact, boolean resolveCollections)Inserts a fact and explicitly specifies itsTypename.default SinsertAs(String type, Iterable<?> objects)Inserts a collection of facts, marking them as being of a specific type.default FactHandleinsertAs(String type, Object fact)Inserts a fact and explicitly specifies itsTypename.default SinsertAs(String type, Object... objects)Inserts a collection of facts, marking them as being of a specific type.SremoveEventListener(SessionLifecycleListener listener)SsetActivationManager(ActivationManager activationManager)SsetExecutionPredicate(BooleanSupplier criteria)Session call's the supplier'sBooleanSupplier.getAsBoolean()method prior to each activation cycle.-
Methods inherited from interface org.evrete.api.Environment
get, get, getPropertyNames
-
Methods inherited from interface org.evrete.api.EvaluationListeners
addListener, removeListener
-
Methods inherited from interface org.evrete.api.EvaluatorsContext
addEvaluator, addEvaluator, getEvaluator, replaceEvaluator, replaceEvaluator
-
Methods inherited from interface org.evrete.api.FluentEnvironment
set
-
Methods inherited from interface org.evrete.api.FluentImports
addImport, addImport, getImports, getJavaImports
-
Methods inherited from interface org.evrete.api.RuleSet
getRule, getRule, getRules, resolveFieldReferences, ruleExists, setRuleBuilderExceptionHandler
-
Methods inherited from interface org.evrete.api.RuntimeContext
builder, compile, compile, getActivationManagerFactory, getClassLoader, getConfiguration, getExpressionResolver, getRuleComparator, getService, getSourceCompiler, getTypeResolver, newRule, newRule, setActivationManagerFactory, setActivationManagerFactory, setActivationMode, setClassLoader, setRuleComparator, wrapTypeResolver
-
-
-
-
Method Detail
-
insert
default FactHandle insert(Object fact)
Inserts a fact in working memory and returns a serializable fact handle.
- Parameters:
fact- object to insert- Returns:
- fact handle assigned to the fact
- Throws:
NullPointerException- if argument is null- See Also:
FactHandle
-
asCollector
<T> Collector<T,?,S> asCollector()
A convenience method that returns an instance of
Collectorfor inserting streams of facts.- Returns:
- collector
-
setExecutionPredicate
S setExecutionPredicate(BooleanSupplier criteria)
Session call's the supplier's
BooleanSupplier.getAsBoolean()method prior to each activation cycle. If the provided value isfalsethen the cycle gets interrupted and session exits its fire(...) method.Along with the
ActivationManager, this method can be used to debug rules, to avoid infinite activation loops, or to prevent excessive consumption of computer resources.- Parameters:
criteria- - boolean value supplier- Returns:
- this session
-
insert0
FactHandle insert0(Object fact, boolean resolveCollections)
Inserts a fact in working memory and returns a serializable fact handle. When
resolveCollectionsis set to true, and the fact is anIterableor an Array, the engine will instead insert its components and return a nullFactHandle.Together with the
insert0(String, Object, boolean)method, this operation constitutes the core insert operations that are actually implemented by the engine. The other insert methods are just convenience wrappers of the two.- Parameters:
fact- object to insertresolveCollections- collection/array inspection flag- Returns:
- fact handle assigned to the fact, or
nullif multiple facts were inserted - Throws:
NullPointerException- if argument is null- See Also:
FactHandle
-
insert0
FactHandle insert0(String type, Object fact, boolean resolveCollections)
Inserts a fact and explicitly specifies its
Typename. WhenresolveCollectionsis set to true, and the fact is anIterableor an Array, the engine will instead insert its components, and return a nullFactHandle.Together with the
insert0(Object, boolean)method, this operation constitutes the core insert operations that are actually implemented by the engine. The other insert methods are just convenience wrappers of the two.- Parameters:
fact- object to insertresolveCollections- collection/array inspection flagtype- type name- Returns:
- fact handle assigned to the fact, or
nullif multiple facts were inserted - Throws:
NullPointerException- if argument is null- See Also:
FactHandle
-
insertAs
default FactHandle insertAs(String type, Object fact)
Inserts a fact and explicitly specifies its
Typename.- Parameters:
type- type namefact- fact to insert- Returns:
- fact handle assigned to the fact
- Throws:
NullPointerException- if argument is null
-
insertAs
default S insertAs(String type, Iterable<?> objects)
Inserts a collection of facts, marking them as being of a specific type.
- Parameters:
type- type nameobjects- objects to insert- See Also:
insertAs(String, Object)
-
insertAs
default S insertAs(String type, Object... objects)
Inserts a collection of facts, marking them as being of a specific type.
- Parameters:
type- type nameobjects- objects to insert- See Also:
insertAs(String, Object)
-
insert
default S insert(Iterable<?> objects)
Inserts a collection of facts.
- Parameters:
objects- objects to insert- See Also:
insert(Object)
-
insert
default S insert(Object... objects)
Inserts an array of facts.
- Parameters:
objects- objects to insert- See Also:
insert(Object)
-
getActivationManager
ActivationManager getActivationManager()
-
setActivationManager
S setActivationManager(ActivationManager activationManager)
-
addEventListener
S addEventListener(SessionLifecycleListener listener)
-
removeEventListener
S removeEventListener(SessionLifecycleListener listener)
-
getParentContext
Knowledge getParentContext()
-
fire
Object fire()
-
-