Interface RhsContext

All Superinterfaces:
SessionOps

public interface RhsContext extends SessionOps
Provides access to the rule's RHS (Right-Hand Side) variables and the session memory's methods.
  • Method Details

    • update

      RhsContext update(Object obj)
      Notifies the working memory that one of its objects has changed. Always call this method to re-evaluate conditions, and avoid calling it if the changes are not relevant to the conditions.
      Parameters:
      obj - the changed object
      Returns:
      the context itself so methods can be chained
    • delete

      RhsContext delete(Object obj)
      Removes an instance from the working memory.
      Parameters:
      obj - the object to remove
      Returns:
      the context itself so methods can be chained
    • getRule

      RuntimeRule getRule()
      Returns a reference to the current rule and its environment.
      Returns:
      the current rule
    • getRuntime

      default RuleSession<?> getRuntime()
      Provides access to the runtime context, equivalent to getRule().getRuntime().
      Returns:
      the runtime context (session)
    • deleteFact

      default RhsContext deleteFact(String factRef)
      Deletes a fact from the working memory by its reference name.
      Parameters:
      factRef - the reference name of the fact to delete
      Returns:
      the context itself so methods can be chained
    • updateFact

      default RhsContext updateFact(String factRef)
      Updates a fact in the working memory by its reference name.
      Parameters:
      factRef - the reference name of the fact to update
      Returns:
      the context itself so methods can be chained
    • getObject

      Object getObject(String name)
      Returns the current fact by its name.
      Parameters:
      name - the name of the fact
      Returns:
      the current instance
    • get

      default <T> T get(String name)
      A typed version of the getObject() method.
      Type Parameters:
      T - the type to cast the fact to
      Parameters:
      name - the name of the fact
      Returns:
      the typed instance
    • get

      default <T> T get(Class<T> type, String name)
      A typed version of the get() method with an explicit generic cast type.
      Type Parameters:
      T - the type to cast the fact to
      Parameters:
      name - the name of the fact
      type - the class type to cast the fact to
      Returns:
      the typed instance