- All Implemented Interfaces:
Environment,EvaluationListeners,EvaluatorsContext,FluentEnvironment<Knowledge>,FluentImports<Knowledge>,Knowledge,RuleSet<RuleDescriptor>,RuleSetContext<Knowledge,,RuleDescriptor> RuntimeContext<Knowledge>
-
Field Summary
FieldsFields inherited from interface org.evrete.api.RuntimeContext
SALIENCE_COMPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddEvaluator(Evaluator evaluator, double complexity) Registers new condition evaluator and returns its handle.Adds an import statement using its string representation.voidaddListener(EvaluationListener listener) Adds a listener to be notified of evaluation events.builder()Returns an instance ofRuleSetBuilderfor building and appending rules to the current context.compile(Collection<LiteralExpression> expressions) A convenience method for compiling literal expressions.configureTypes(Consumer<TypeResolver> action) Configures theTypeResolverby applying the given action.<T> TRetrieves the value of a property by its name.Class<? extends ActivationManager>Returns the Activation Manager factory class for this RuntimeContext.Retrieves the ClassLoader used by the current context.Retrieves the Configuration object associated with this RuntimeContext.getEvaluator(EvaluatorHandle handle) Returns evaluator by its handle.Retrieves the expression resolver for parsing string expressions.Retrieves the current set of import statements.Retrieves a collection of all property names in the environment.final RuleDescriptorRetrieves a rule based on its name.Retrieves the comparator used for ordering rules.final List<RuleDescriptor>getRules()Method returns a list of rules created so far.Returns theKnowledgeServiceinstance.Retrieves a collection of active RuleSessions associated with the Knowledge.Creates and returns a new instance ofJavaSourceCompiler.Retrieves the TypeResolver instance associated with this RuntimeContext.newRule()Deprecated.Deprecated.voidremoveListener(EvaluationListener listener) Removes a previously added listener.voidreplaceEvaluator(EvaluatorHandle handle, Evaluator newEvaluator) Replaces existing condition with a new one.voidreplaceEvaluator(EvaluatorHandle handle, ValuesPredicate predicate) Replaces existing condition with a new one.final FieldReference[]resolveFieldReferences(String[] args, NamedType.Resolver typeMapper) protected Knowledgeself()Sets the specified property to the given value.<A extends ActivationManager>
voidsetActivationManagerFactory(Class<A> managerClass) Sets the Activation Manager factory class for this RuntimeContext.voidsetActivationManagerFactory(String managerClass) Sets the Activation Manager factory class name for this RuntimeContext.setActivationMode(ActivationMode activationMode) Sets the activation mode for the session.voidsetClassLoader(ClassLoader classLoader) Sets new parent classloader for this context's internal classloader.voidsetRuleComparator(Comparator<Rule> comparator) Sets the comparator used for ordering rules.voidwrapTypeResolver(TypeResolverWrapper wrapper) Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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.Knowledge
activationManager, newStatefulSession, newStatelessSessionMethods inherited from interface org.evrete.api.RuleSet
getRule, getRule, getRules, resolveFieldReferences, ruleExists, setRuleBuilderExceptionHandlerMethods inherited from interface org.evrete.api.RuntimeContext
builder, compile, compile, configureTypes, getActivationManagerFactory, getClassLoader, getConfiguration, getExpressionResolver, getRuleComparator, getService, getSourceCompiler, getTypeResolver, newRule, newRule, setActivationManagerFactory, setActivationManagerFactory, setActivationMode, setClassLoader, setRuleComparator, wrapTypeResolver
-
Field Details
-
delegate
-
-
Constructor Details
-
KnowledgeWrapper
-
-
Method Details
-
getSessions
Description copied from interface:KnowledgeRetrieves a collection of active RuleSessions associated with the Knowledge.- Specified by:
getSessionsin interfaceKnowledge- Returns:
- a collection of RuleSessions
-
newStatefulSession
- Specified by:
newStatefulSessionin interfaceKnowledge- Returns:
- new stateful session
-
newStatelessSession
- Specified by:
newStatelessSessionin interfaceKnowledge- Returns:
- new stateless session
-
get
Description copied from interface:EnvironmentRetrieves the value of a property by its name.- Specified by:
getin interfaceEnvironment- Type Parameters:
T- The expected type of the property value.- Parameters:
property- The name of the property to retrieve.- Returns:
- The value of the property as type T, or
nullif it does not exist.
-
getPropertyNames
Description copied from interface:EnvironmentRetrieves a collection of all property names in the environment.- Specified by:
getPropertyNamesin interfaceEnvironment- Returns:
- A collection of strings representing all property names in the environment.
-
addListener
Description copied from interface:EvaluationListenersAdds a listener to be notified of evaluation events. If the listener is already added, behavior depends on the implementation.- Specified by:
addListenerin interfaceEvaluationListeners- Parameters:
listener- the listener to add, notnull.
-
removeListener
Description copied from interface:EvaluationListenersRemoves a previously added listener. If the listener is not registered, this method has no effect.- Specified by:
removeListenerin interfaceEvaluationListeners- Parameters:
listener- the listener to remove, notnull.
-
compile
public Collection<LiteralEvaluator> compile(Collection<LiteralExpression> expressions) throws CompilationException Description copied from interface:RuntimeContextA convenience method for compiling literal expressions.
- Specified by:
compilein interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
expressions- literal conditions and their context- Returns:
- compiled literal conditions
- Throws:
CompilationException- if the expression failed to compile
-
resolveFieldReferences
- Specified by:
resolveFieldReferencesin interfaceRuleSet<D extends RuleSetContext<C,R>>
-
getRule
Description copied from interface:RuleSetRetrieves a rule based on its name.- Specified by:
getRulein interfaceRuleSet<D extends RuleSetContext<C,R>> - Parameters:
name- the name of the rule to retrieve- Returns:
- the rule with the specified name, or null if no rule with that name exists
-
set
Description copied from interface:FluentEnvironmentSets the specified property to the given value.- Specified by:
setin interfaceEnvironment- Specified by:
setin interfaceFluentEnvironment<D extends RuleSetContext<C,R>> - Parameters:
property- the name of the property to set; should not benull.value- the new value for the property; the actual type is determined by the implementation and the property being set.- Returns:
- the current instance of
Xto allow for method chaining.
-
configureTypes
Description copied from interface:RuntimeContextConfigures theTypeResolverby applying the given action.- Specified by:
configureTypesin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
action- the action to configure the TypeResolver- Returns:
- this context
-
setClassLoader
Description copied from interface:RuntimeContextSets new parent classloader for this context's internal classloader.
- Specified by:
setClassLoaderin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
classLoader- this context's new parent classloader
-
self
-
addImport
Description copied from interface:FluentImportsAdds an import statement using its string representation.- Specified by:
addImportin interfaceFluentImports<D extends RuleSetContext<C,R>> - Parameters:
imp- the full canonical name of the class or package to be imported- Returns:
- this instance to allow for method chaining
-
getRules
Description copied from interface:RuleSetMethod returns a list of rules created so far.
- Specified by:
getRulesin interfaceRuleSet<D extends RuleSetContext<C,R>> - Returns:
- list of currently known rules
-
getImports
Description copied from interface:FluentImportsRetrieves the current set of import statements.- Specified by:
getImportsin interfaceFluentImports<D extends RuleSetContext<C,R>> - Returns:
- an
Importsobject containing the current set of import statements
-
getRuleComparator
Description copied from interface:RuntimeContextRetrieves the comparator used for ordering rules.- Specified by:
getRuleComparatorin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the comparator for Rule objects.
-
setRuleComparator
Description copied from interface:RuntimeContextSets the comparator used for ordering rules.- Specified by:
setRuleComparatorin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
comparator- the comparator for Rule objects.
-
newRule
Deprecated.Description copied from interface:RuntimeContextCreates a new rule with the provided name.- Specified by:
newRulein interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
name- rule name- Returns:
- a new rule builder
-
newRule
Deprecated.Description copied from interface:RuntimeContextCreates a new unnamed rule.- Specified by:
newRulein interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- a new rule builder
-
builder
Description copied from interface:RuntimeContextReturns an instance of
RuleSetBuilderfor building and appending rules to the current context.Builder MUST be terminated with the
RuleSetBuilder.build()call for changes to take effect.Usage BEFORE 3.1.00:
Usage AFTER 3.1.00:service .newKnowledge() .newRule() .forEach("$a", A.class) .where("$a.active") .execute();service .newKnowledge() .builder() // !! important .newRule() .forEach("$a", A.class) .where("$a.active") .execute() .build(); // !! important- Specified by:
builderin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- new instance of RuleSetBuilder.
-
wrapTypeResolver
Deprecated.Description copied from interface:RuntimeContextWraps the provided TypeResolver with a TypeResolverWrapper instance.- Specified by:
wrapTypeResolverin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
wrapper- the TypeResolverWrapper instance used to wrap the TypeResolver
-
setActivationMode
Description copied from interface:RuntimeContextSets the activation mode for the session.- Specified by:
setActivationModein interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
activationMode- the activation mode to set- Returns:
- the updated instance of the class
-
addEvaluator
Description copied from interface:EvaluatorsContextRegisters new condition evaluator and returns its handle. If an existing
Evaluatormatches the argument (Evaluator.compare(Evaluator)returnsEvaluator.RELATION_EQUALS), the existing evaluator handle will be returned instead and no changes will be made in the context.- Specified by:
addEvaluatorin interfaceEvaluatorsContext- Parameters:
evaluator- condition to addcomplexity- condition's relative complexity- Returns:
- new
EvaluatorHandleor the one of an existing condition.
-
replaceEvaluator
Description copied from interface:EvaluatorsContextReplaces existing condition with a new one. New condition must have the same
Evaluator.descriptor(), otherwiseIllegalArgumentExceptionwill be thrown.- Specified by:
replaceEvaluatorin interfaceEvaluatorsContext- Parameters:
handle- handle of an existing conditionnewEvaluator- new condition
-
getEvaluator
Description copied from interface:EvaluatorsContextReturns evaluator by its handle.
- Specified by:
getEvaluatorin interfaceEvaluatorsContext- Parameters:
handle- evaluator handle- Returns:
- existing condition evaluator or null if such condition does not exist
-
replaceEvaluator
Description copied from interface:EvaluatorsContextReplaces existing condition with a new one.
- Specified by:
replaceEvaluatorin interfaceEvaluatorsContext- Parameters:
handle- handle of an existing conditionpredicate- new condition in a form ifValuesPredicate
-
getExpressionResolver
Description copied from interface:RuntimeContextRetrieves the expression resolver for parsing string expressions.- Specified by:
getExpressionResolverin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the expression resolver
-
getClassLoader
Description copied from interface:RuntimeContextRetrieves the ClassLoader used by the current context.- Specified by:
getClassLoaderin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the ClassLoader used by the object.
-
getService
Description copied from interface:RuntimeContextReturns theKnowledgeServiceinstance.- Specified by:
getServicein interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the
KnowledgeServiceinstance
-
getActivationManagerFactory
Description copied from interface:RuntimeContextReturns the Activation Manager factory class for this RuntimeContext.- Specified by:
getActivationManagerFactoryin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the Activation Manager factory class
-
setActivationManagerFactory
Description copied from interface:RuntimeContextSets the Activation Manager factory class for this RuntimeContext.- Specified by:
setActivationManagerFactoryin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Type Parameters:
A- the type of Activation Manager- Parameters:
managerClass- the Activation Manager factory class
-
setActivationManagerFactory
Description copied from interface:RuntimeContextSets the Activation Manager factory class name for this RuntimeContext.- Specified by:
setActivationManagerFactoryin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
managerClass- the Activation Manager factory class name
-
getTypeResolver
Description copied from interface:RuntimeContextRetrieves the TypeResolver instance associated with this RuntimeContext.- Specified by:
getTypeResolverin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the TypeResolver instance
-
getConfiguration
Description copied from interface:RuntimeContextRetrieves the Configuration object associated with this RuntimeContext.- Specified by:
getConfigurationin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the Configuration object
-
getSourceCompiler
Description copied from interface:RuntimeContextCreates and returns a new instance ofJavaSourceCompiler.- Specified by:
getSourceCompilerin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- A new
JavaSourceCompilerinstance.
-