org.eclipse.viatra.transformation.evm.api

## Class RuleEngine

- java.lang.Object
- - org.eclipse.viatra.transformation.evm.api.RuleEngine

- Direct Known Subclasses:
    ExecutionSchema

      public class RuleEngine
      extends java.lang.Object

  A rule engine is a facade for accessing the EVM, it allows the retrieval of all activations and filtered access by state, specification or both. It also allows the addition or removal of rules.
  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `RuleEngine(RuleBase ruleBase)` Creates a rule engine for the given ruleBase

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<EventAtom> boolean` | `addRule(RuleSpecification<EventAtom> specification)` Adds a rule specification to the RuleBase.
    `<EventAtom> boolean` | `addRule(RuleSpecification<EventAtom> specification, EventFilter<? super EventAtom> filter)` Adds a rule specification to the RuleBase with the given filter.
    `<EventAtom> boolean` | `containsRule(RuleSpecification<EventAtom> specification)` Decides whether a rule specification is already added to the RuleBase without filter.
    `<EventAtom> boolean` | `containsRule(RuleSpecification<EventAtom> specification, EventFilter<? super EventAtom> filter)` Decides whether a rule specification is already added to the RuleBase with the specified filter.
    `static RuleEngine` | `create(RuleBase ruleBase)` Creates a rule engine for the given ruleBase
    `ScopedConflictSet` | `createScopedConflictSet(ConflictResolver conflictResolver, java.util.Map<RuleSpecification<?>,java.util.Set<EventFilter<?>>> specifications)`
    `ScopedConflictSet` | `createScopedConflictSet(java.util.Map<RuleSpecification<?>,java.util.Set<EventFilter<?>>> specifications)`
    `<EventAtom> ScopedConflictSet` | `createScopedConflictSet(RuleSpecification<EventAtom> specification, EventFilter<? super EventAtom> eventFilter)`
    `void` | `dispose()` Disposes of the rule base.
    `java.util.Map<ActivationState,java.util.Set<Activation<?>>>` | `getActivations()`
    `java.util.Set<Activation<?>>` | `getActivations(ActivationState state)`
    `<EventAtom> java.util.Set<Activation<EventAtom>>` | `getActivations(RuleSpecification<EventAtom> specification)`
    `<EventAtom> java.util.Set<Activation<EventAtom>>` | `getActivations(RuleSpecification<EventAtom> specification, ActivationState state)`
    `<EventAtom> java.util.Set<Activation<EventAtom>>` | `getActivations(RuleSpecification<EventAtom> specification, EventFilter<? super EventAtom> filter)`
    `<EventAtom> java.util.Set<Activation<EventAtom>>` | `getActivations(RuleSpecification<EventAtom> specification, EventFilter<? super EventAtom> filter, ActivationState state)`
    `java.util.Set<Activation<?>>` | `getConflictingActivations()`
    `EventRealm` | `getEventRealm()`
    `org.apache.log4j.Logger` | `getLogger()`
    `Activation<?>` | `getNextActivation()`
    `protected RuleBase` | `getRuleBase()`
    `java.util.Map<RuleSpecification<?>,java.util.Set<EventFilter<?>>>` | `getRuleSpecificationMultimap()`
    `<EventAtom> boolean` | `removeRule(RuleSpecification<EventAtom> specification)` Removes the given not-filtered rule from the EVM.
    `<EventAtom> boolean` | `removeRule(RuleSpecification<EventAtom> specification, EventFilter<? super EventAtom> filter)` Removes the given filtered rule from the EVM.
    `void` | `setConflictResolver(ConflictResolver conflictResolver)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RuleEngine

          protected RuleEngine(RuleBase ruleBase)

      Creates a rule engine for the given ruleBase
      Parameters:
        `ruleBase` -

  - ### Method Detail

    - #### create

          public static RuleEngine create(RuleBase ruleBase)

      Creates a rule engine for the given ruleBase
      Parameters:
        `ruleBase` -
      Returns:
        the created facade

    - #### setConflictResolver

          public void setConflictResolver(ConflictResolver conflictResolver)

    - #### createScopedConflictSet

          public <EventAtom> ScopedConflictSet createScopedConflictSet(RuleSpecification<EventAtom> specification,
                                                                       EventFilter<? super EventAtom> eventFilter)

    - #### createScopedConflictSet

          public ScopedConflictSet createScopedConflictSet(java.util.Map<RuleSpecification<?>,java.util.Set<EventFilter<?>>> specifications)

      Since:
        2.0

    - #### createScopedConflictSet

          public ScopedConflictSet createScopedConflictSet(ConflictResolver conflictResolver,
                                                           java.util.Map<RuleSpecification<?>,java.util.Set<EventFilter<?>>> specifications)

      Since:
        2.0

    - #### addRule

          public <EventAtom> boolean addRule(RuleSpecification<EventAtom> specification)

      Adds a rule specification to the RuleBase. If the rule already exists, no change occurs in the set of rules.
      Parameters:
        `specification` -
      Returns:
        true if the rule was added, false if it already existed

    - #### addRule

          public <EventAtom> boolean addRule(RuleSpecification<EventAtom> specification,
                                             EventFilter<? super EventAtom> filter)

      Adds a rule specification to the RuleBase with the given filter. If the rule already exists, no change occurs in the set of rules.
      Parameters:
        `specification` -
        `filter` - the partial match to be used as a filter for activations
      Returns:
        true if the rule was added, false if it already existed

    - #### containsRule

          public <EventAtom> boolean containsRule(RuleSpecification<EventAtom> specification)

      Decides whether a rule specification is already added to the RuleBase without filter.

    - #### containsRule

          public <EventAtom> boolean containsRule(RuleSpecification<EventAtom> specification,
                                                  EventFilter<? super EventAtom> filter)

      Decides whether a rule specification is already added to the RuleBase with the specified filter.

    - #### getActivations

          public java.util.Map<ActivationState,java.util.Set<Activation<?>>> getActivations()

      Returns:
        a copy of the multimap containing all activations
      Since:
        2.0

    - #### getNextActivation

          public Activation<?> getNextActivation()

      Returns:
        the next enabled activation if exists, selected by the conflict resolver

    - #### getConflictingActivations

          public java.util.Set<Activation<?>> getConflictingActivations()

      Returns:
        an immutable set of conflicting activations

    - #### getActivations

          public java.util.Set<Activation<?>> getActivations(ActivationState state)

      Parameters:
        `state` -
      Returns:
        an immutable set of the activations in the given state

    - #### getActivations

          public <EventAtom> java.util.Set<Activation<EventAtom>> getActivations(RuleSpecification<EventAtom> specification)

      Parameters:
        `specification` -
      Returns:
        the immutable set of activations of the given specification

    - #### getActivations

          public <EventAtom> java.util.Set<Activation<EventAtom>> getActivations(RuleSpecification<EventAtom> specification,
                                                                                 EventFilter<? super EventAtom> filter)

      Parameters:
        `specification` -
        `filter` -
      Returns:
        the immutable set of activations of the given filtered specification

    - #### getActivations

          public <EventAtom> java.util.Set<Activation<EventAtom>> getActivations(RuleSpecification<EventAtom> specification,
                                                                                 ActivationState state)

      Parameters:
        `specification` -
        `state` -
      Returns:
        the immutable set of activations of the given specification with the given state

    - #### getActivations

          public <EventAtom> java.util.Set<Activation<EventAtom>> getActivations(RuleSpecification<EventAtom> specification,
                                                                                 EventFilter<? super EventAtom> filter,
                                                                                 ActivationState state)

      Parameters:
        `specification` -
        `filter` -
        `state` -
      Returns:
        the immutable set of activations of the given specification with the given state

    - #### getRuleSpecificationMultimap

          public java.util.Map<RuleSpecification<?>,java.util.Set<EventFilter<?>>> getRuleSpecificationMultimap()

      Returns:
        the immutable set of rules in the EVM
      Since:
        2.0

    - #### removeRule

          public <EventAtom> boolean removeRule(RuleSpecification<EventAtom> specification)

      Removes the given not-filtered rule from the EVM.
      Parameters:
        `specification` -
      Returns:
        true, if the rule existed

    - #### removeRule

          public <EventAtom> boolean removeRule(RuleSpecification<EventAtom> specification,
                                                EventFilter<? super EventAtom> filter)

      Removes the given filtered rule from the EVM.
      Parameters:
        `specification` -
        `filter` - the partial match used as a filter
      Returns:
        true, if the rule existed

    - #### getRuleBase

          protected RuleBase getRuleBase()

    - #### getEventRealm

          public EventRealm getEventRealm()

      Returns:
        the event realm of the rule base

    - #### getLogger

          public org.apache.log4j.Logger getLogger()

    - #### dispose

          public void dispose()

      Disposes of the rule base.