Interface RhsContext


public interface RhsContext

Rule activation context that provides access to the rule's variables and working memory methods.

  • Method Details

    • insert

      RhsContext insert​(Object obj)

      Inserts a new object into the working memory.

      Parameters:
      obj - the object
      Returns:
      the context itself so the methods could be chained
    • insert

      default RhsContext insert​(Collection<?> objects)
    • insert

      default RhsContext insert​(Object[] objects)
    • update

      RhsContext update​(Object obj)

      This method lets the working memory know that one of its objects has changed. Always call this method to get conditions re-evaluated, and avoid calling it if the changes are not relevant to the conditions.

      Parameters:
      obj - the changed object
      Returns:
      the context itself so the methods could be chained
    • delete

      RhsContext delete​(Object obj)

      This method removes an instance from the working memory.

      Parameters:
      obj - the object to remove
      Returns:
      the context itself so the methods could be chained
    • getFact

      RuntimeFact getFact​(String name)

      Returns a fact reference by its name, specified in the LHS

      Parameters:
      name - the fact name
      Returns:
      current inner fact representation with a reference to the inserted instance
    • getRule

      RuntimeRule getRule()

      A convenience method that returns reference to the current rule and its environment.

      Returns:
      current rule
    • getRuntime

      default RuntimeContext<?> getRuntime()

      Provides access to the runtime context, an equivalent to getRule().getRuntime().

      Returns:
      runtime context (session)
    • deleteFact

      default RhsContext deleteFact​(String factRef)
    • updateFact

      default RhsContext updateFact​(String factRef)
    • getObject

      default Object getObject​(String name)

      Returns current fact by its name

      Parameters:
      name - the fact name
      Returns:
      current instance
    • get

      default <T> T get​(String name)

      A typed version of the getObject() method.

      Type Parameters:
      T - cast type
      Parameters:
      name - fact name
      Returns:
      current instance