Interface FactStorage<T>

Type Parameters:
T - the type of facts that this storage system handles
All Superinterfaces:
Iterable<FactStorage.Entry<T>>, ReIterable<FactStorage.Entry<T>>

public interface FactStorage<T> extends ReIterable<FactStorage.Entry<T>>
Represents a storage system for facts, allowing for operations such as insertion, deletion, updating, and retrieval of facts. This storage system essentially acts as a mapping between fact handles (unique identifiers for facts) and the facts themselves. The engine creates a FactStorage instance for each declared fact of a specific Type.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Represents an entry in the storage, holding both a fact handle and the fact instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears all facts from the storage.
    void
    Deletes a fact from the storage, identified by the provided handle.
    Retrieves the fact associated with the provided handle.
    insert(T fact)
    Creates and returns new FactHandle for each inserted fact.
    void
    update(FactHandle handle, T newInstance)
    Updates an existing fact in the storage with a new instance, identified by the provided handle.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface org.evrete.api.ReIterable

    iterator, iterator
  • Method Details

    • insert

      FactHandle insert(T fact)

      Creates and returns new FactHandle for each inserted fact. The contract is that the implementation must return null if object is already known and not deleted.

      Parameters:
      fact - the fact being inserted in the working memory
      Returns:
      null if object has been already inserted or a new FactHandle otherwise
    • delete

      void delete(FactHandle handle)
      Deletes a fact from the storage, identified by the provided handle.
      Parameters:
      handle - the handle of the fact to be deleted
    • update

      void update(FactHandle handle, T newInstance)
      Updates an existing fact in the storage with a new instance, identified by the provided handle.
      Parameters:
      handle - the handle of the fact to be updated
      newInstance - the new instance to replace the existing fact
    • getFact

      T getFact(FactHandle handle)
      Retrieves the fact associated with the provided handle.
      Parameters:
      handle - the handle whose associated fact is to be retrieved
      Returns:
      the fact associated with the provided handle
    • clear

      void clear()
      Clears all facts from the storage.