Interface StatefulSession

    • Method Detail

      • update

        StatefulSession 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
      • getFact

        <T> T getFact​(FactHandle handle)

        Returns fact by its handle.

        Type Parameters:
        T - type of the fact (use Object or wildcard if type is unknown)
        Parameters:
        handle - fact handle
        Returns:
        fact or null if fact is not found
      • fireAsync

        <T> Future<T> fireAsync​(T result)

        Fires session asynchronously and returns a Future representing the session execution status.

        Type Parameters:
        T - result type parameter
        Parameters:
        result - the result to return by the Future
        Returns:
        a Future representing pending completion of the fire() command
        Throws:
        RejectedExecutionException - if the task cannot be scheduled for execution
      • close

        void close()

        Closes the session and destroys its memory. A closed session can not be reused.

        Specified by:
        close in interface AutoCloseable
      • clear

        void clear()

        This method clears session's working memory and its beta-memory nodes as if the session had never been used.

      • forEachFact

        default <T> StatefulSession forEachFact​(Class<T> type,
                                                Consumer<T> consumer)

        A memory inspection method that accepts fact type as an argument.

        Type Parameters:
        T - expected java type for the provided type name
        Parameters:
        type - expected fact type
        consumer - consumer for the facts
        Throws:
        ClassCastException - if a working memory object can not be cast to the specified type
        IllegalArgumentException - if no such type exists
        See Also:
        TypeResolver
      • forEachFact

        <T> StatefulSession forEachFact​(String type,
                                        Consumer<T> consumer)

        A memory inspection method that accepts fact type as an argument. Type name can be either a class name or a name of explicitly declared type. In the latter case, the generic type parameter T must match the declared type's Java type (see Type.getJavaType())

        Type Parameters:
        T - expected java type for the provided type name
        Parameters:
        type - type name
        consumer - consumer for the facts
        Throws:
        ClassCastException - if a working memory object can not be cast to the specified type
        IllegalArgumentException - if no such type exists
        See Also:
        TypeResolver