Interface RuleSession<S extends RuleSession<S>>

    • Method Detail

      • insert

        default 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
      • asCollector

        <T> Collector<T,​?,​S> asCollector()

        A convenience method that returns an instance of Collector for inserting streams of facts.

        Returns:
        collector
      • setExecutionPredicate

        S setExecutionPredicate​(BooleanSupplier criteria)

        Session call's the supplier's BooleanSupplier.getAsBoolean() method prior to each activation cycle. If the provided value is false then the cycle gets interrupted and session exits its fire(...) method.

        Along with the ActivationManager, this method can be used to debug rules, to avoid infinite activation loops, or to prevent excessive consumption of computer resources.

        Parameters:
        criteria - - boolean value supplier
        Returns:
        this session
      • insert0

        FactHandle insert0​(Object fact,
                           boolean resolveCollections)

        Inserts a fact in working memory and returns a serializable fact handle. When resolveCollections is set to true, and the fact is an Iterable or an Array, the engine will instead insert its components and return a null FactHandle.

        Together with the insert0(String, Object, boolean) method, this operation constitutes the core insert operations that are actually implemented by the engine. The other insert methods are just convenience wrappers of the two.

        Parameters:
        fact - object to insert
        resolveCollections - collection/array inspection flag
        Returns:
        fact handle assigned to the fact, or null if multiple facts were inserted
        Throws:
        NullPointerException - if argument is null
        See Also:
        FactHandle
      • insert0

        FactHandle insert0​(String type,
                           Object fact,
                           boolean resolveCollections)

        Inserts a fact and explicitly specifies its Type name. When resolveCollections is set to true, and the fact is an Iterable or an Array, the engine will instead insert its components, and return a null FactHandle.

        Together with the insert0(Object, boolean) method, this operation constitutes the core insert operations that are actually implemented by the engine. The other insert methods are just convenience wrappers of the two.

        Parameters:
        fact - object to insert
        resolveCollections - collection/array inspection flag
        type - type name
        Returns:
        fact handle assigned to the fact, or null if multiple facts were inserted
        Throws:
        NullPointerException - if argument is null
        See Also:
        FactHandle
      • insertAs

        default FactHandle insertAs​(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
      • insertAs

        default S insertAs​(String type,
                           Iterable<?> objects)

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

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

        default S insertAs​(String type,
                           Object... objects)

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

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

        default S insert​(Iterable<?> objects)

        Inserts a collection of facts.

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

        default S insert​(Object... objects)

        Inserts an array of facts.

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

        Knowledge getParentContext()