Interface RuleSession<S extends RuleSession<S>>

All Superinterfaces:
AutoCloseable, Environment, EvaluationListeners, EvaluatorsContext, FluentEnvironment<S>, FluentImports<RuntimeContext<?>>, RuleSet<RuntimeRule>, RuntimeContext<S>, WorkingMemory
All Known Subinterfaces:
StatefulSession

public interface RuleSession<S extends RuleSession<S>>
extends WorkingMemory, RuntimeContext<S>, RuleSet<RuntimeRule>, AutoCloseable
  • Method Details

    • getActivationManager

      ActivationManager getActivationManager()
    • setActivationManager

      S setActivationManager​(ActivationManager activationManager)
    • forEachFact

      void forEachFact​(BiConsumer<FactHandle,​Object> consumer)
    • forEachFact

      default <T> void forEachFact​(Class<T> type, Consumer<T> consumer)

      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 type
      consumer - consumer for the facts
      Throws:
      ClassCastException - if a working memory object can not be cast to the specified type
      IllegalArgumentException - if no such type exists
      See Also:
      TypeResolver
    • forEachFact

      <T> void forEachFact​(String type, Consumer<T> consumer)

      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 T must match the declared type's Java type (see Type.getJavaType())

      Type Parameters:
      T - expected java type for the provided type name
      Parameters:
      type - type name
      consumer - consumer for the facts
      Throws:
      ClassCastException - if a working memory object can not be cast to the specified type
      IllegalArgumentException - if no such type exists
      See Also:
      TypeResolver
    • forEachFact

      default <T> void forEachFact​(Class<T> type, Predicate<T> filter, Consumer<T> consumer)

      A filtering version of the forEachFact(Class, Consumer) method.

      Type Parameters:
      T - expected java type for the provided type name
      Parameters:
      type - expected fact type
      consumer - consumer for the facts
      filter - filtering predicate
      See Also:
      forEachFact(Class, Consumer)
    • forEachFact

      default <T> void forEachFact​(String type, Predicate<T> filter, Consumer<T> consumer)

      A filtering version of the forEachFact(String, Consumer) method.

      Type Parameters:
      T - expected java type for the provided type name
      Parameters:
      type - expected fact type
      consumer - consumer for the facts
      filter - filtering predicate
      See Also:
      forEachFact(String, Consumer)
    • getParentContext

      RuntimeContext<?> getParentContext()
    • fire

      void fire()
    • fireAsync

      <T> Future<T> fireAsync​(T result)

      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

      default Future<S> 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:
      fireAsync(Object)
    • close

      void close()
      Specified by:
      close in interface AutoCloseable
    • clear

      void clear()