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
All Known Implementing Classes:
AbstractSessionWrapper

public interface RuleSession<S extends RuleSession<S>> extends RuleSetContext<S,RuntimeRule>

Base interface for both stateful and stateless sessions

  • Method Details

    • 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:
    • asCollector

      <T> Collector<T,?,S> asCollector()

      A convenience method that returns an instance of Collector for inserting streams of facts.

      Type Parameters:
      T - the type of input elements to the reduction operation
      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 is false then 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 resolveCollections is set to true, and the fact is an Iterable or an Array, the engine will instead insert its components and return a null FactHandle.

      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 insert
      resolveCollections - collection/array inspection flag
      Returns:
      fact handle assigned to the fact, or null if multiple facts were inserted
      Throws:
      NullPointerException - if argument is null
      See Also:
    • insert0

      FactHandle insert0(String type, Object fact, boolean resolveCollections)

      Inserts a fact and explicitly specifies its Type name. When resolveCollections is set to true, and the fact is an Iterable or an Array, the engine will instead insert its components, and return a null FactHandle.

      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 insert
      resolveCollections - collection/array inspection flag
      type - type name
      Returns:
      fact handle assigned to the fact, or null if multiple facts were inserted
      Throws:
      NullPointerException - if argument is null
      See Also:
    • insertAs

      default FactHandle insertAs(String type, Object fact)

      Inserts a fact and explicitly specifies its Type name.

      Parameters:
      type - type name
      fact - 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 name
      objects - objects to insert
      Returns:
      this instance
      See Also:
    • insertAs

      default S insertAs(String type, Object... objects)

      Inserts a collection of facts, marking them as being of a specific type.

      Parameters:
      type - type name
      objects - objects to insert
      Returns:
      this instance
      See Also:
    • insert

      default S insert(Iterable<?> objects)

      Inserts a collection of facts.

      Parameters:
      objects - objects to insert
      Returns:
      this instance
      See Also:
    • insert

      default S insert(Object... objects)

      Inserts an array of facts.

      Parameters:
      objects - objects to insert
      Returns:
      this instance
      See Also:
    • getActivationManager

      ActivationManager getActivationManager()
    • setActivationManager

      S setActivationManager(ActivationManager activationManager)
    • addEventListener

      S addEventListener(SessionLifecycleListener listener)
    • removeEventListener

      S removeEventListener(SessionLifecycleListener listener)
    • getParentContext

      Knowledge getParentContext()
    • fire

      Object fire()