org.eclipse.incquery.runtime.evm.api

## Class RuleEngine

- java.lang.Object
- - org.eclipse.incquery.runtime.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.
  Author:
    Abel Hegedus

- - ### 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, com.google.common.collect.Multimap<RuleSpecification<?>,EventFilter<?>> specifications)`
    `ScopedConflictSet` | `createScopedConflictSet(com.google.common.collect.Multimap<RuleSpecification<?>,EventFilter<?>> specifications)`
    `<EventAtom> ScopedConflictSet` | `createScopedConflictSet(RuleSpecification<EventAtom> specification, EventFilter<? super EventAtom> eventFilter)`
    `void` | `dispose()` Disposes of the rule base.
    `com.google.common.collect.Multimap<ActivationState,Activation<?>>` | `getActivations()`
    `java.util.Set<Activation<?>>` | `getActivations(IncQueryActivationStateEnum 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()`
    `com.google.common.collect.Multimap<RuleSpecification<?>,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

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

- - ### 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(com.google.common.collect.Multimap<RuleSpecification<?>,EventFilter<?>> specifications)

    - #### createScopedConflictSet

          public ScopedConflictSet createScopedConflictSet(ConflictResolver conflictResolver,
                                                           com.google.common.collect.Multimap<RuleSpecification<?>,EventFilter<?>> specifications)

    - #### 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 com.google.common.collect.Multimap<ActivationState,Activation<?>> getActivations()

      Returns:
        a copy of the multimap containing all activations

    - #### 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(IncQueryActivationStateEnum 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 com.google.common.collect.Multimap<RuleSpecification<?>,EventFilter<?>> getRuleSpecificationMultimap()

      Returns:
        the immutable set of rules in the EVM

    - #### 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

    - #### 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.