- 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>getEvaluator(EvaluatorHandle handle) Returns evaluator by its handle.Retrieves the current set of import statements.Retrieves a collection of all property names in the environment.final RuleDescriptorfinal List<RuleDescriptor>getRules()Method returns a list of rules created so far.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) voidsetActivationManagerFactory(String managerClass) setActivationMode(ActivationMode activationMode) voidsetClassLoader(ClassLoader classLoader) Sets new parent classloader for this context's internal classloader.voidsetRuleComparator(Comparator<Rule> comparator) 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
- Specified by:
getSessionsin interfaceKnowledge
-
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
- Specified by:
getRulein interfaceRuleSet<D extends RuleSetContext<C,R>>
-
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
- Specified by:
getRuleComparatorin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
setRuleComparator
- Specified by:
setRuleComparatorin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
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
- Specified by:
setActivationModein interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
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
- Specified by:
getExpressionResolverin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
getClassLoader
- Specified by:
getClassLoaderin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
getService
- Specified by:
getServicein interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
getActivationManagerFactory
- Specified by:
getActivationManagerFactoryin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
setActivationManagerFactory
- Specified by:
setActivationManagerFactoryin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
setActivationManagerFactory
- Specified by:
setActivationManagerFactoryin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
getTypeResolver
- Specified by:
getTypeResolverin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
getConfiguration
- Specified by:
getConfigurationin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-
getSourceCompiler
- Specified by:
getSourceCompilerin interfaceRuntimeContext<D extends RuleSetContext<C,R>>
-