Interface WorkingMemory

All Known Subinterfaces:
RuleSession<S>, StatefulSession

public interface WorkingMemory

An interface that every rule session implements and that describes operations on facts that are available to developers.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    delete​(FactHandle handle)
    Deletes a fact from working memory.
    getFact​(FactHandle handle)
    Returns fact by its handle.
    insert​(Object fact)
    Inserts a fact in working memory and returns a serializable fact handle.
    default void
    insert​(Object... objects)
    Inserts an array of facts.
    insert​(String type, Object fact)
    Inserts a fact and explicitly specifies its Type name.
    default void
    insert​(String type, Collection<?> objects)
    Inserts a collection of facts, marking them as being of a specific type.
    default void
    insert​(Collection<?> objects)
    Inserts a collection of facts.
    void
    update​(FactHandle handle, Object newValue)
    Updates a fact that already exists in the working memory
  • Method Details

    • insert

      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:
      FactHandle
    • getFact

      Object getFact(FactHandle handle)

      Returns fact by its handle.

      Parameters:
      handle - fact handle
      Returns:
      fact or null if fact is not found
    • insert

      FactHandle insert(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
    • update

      void update(FactHandle handle, Object newValue)

      Updates a fact that already exists in the working memory

      Parameters:
      handle - fact handle, previously assigned to original fact
      newValue - an updated version of the fact
    • delete

      void delete(FactHandle handle)

      Deletes a fact from working memory.

      Parameters:
      handle - fact handle
    • insert

      default void insert(String type, Collection<?> objects)

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

      Parameters:
      type - type name
      objects - objects to insert
      See Also:
      insert(String, Object)
    • insert

      default void insert(Collection<?> objects)

      Inserts a collection of facts.

      Parameters:
      objects - objects to insert
      See Also:
      insert(Object)
    • insert

      default void insert(Object... objects)

      Inserts an array of facts.

      Parameters:
      objects - objects to insert
      See Also:
      insert(Object)