org.eclipse.incquery.runtime.evm.api

## Class RuleInstance<EventAtom>

- java.lang.Object
- - org.eclipse.incquery.runtime.evm.api.RuleInstance<EventAtom>

- All Implemented Interfaces:
    IActivationNotificationProvider

      public class RuleInstance<EventAtom>
      extends java.lang.Object
      implements IActivationNotificationProvider

  The rule instance is created in the EVM for a rule specification. The instance manages the set of activations and processes events that affect the instance and its activations. It uses the life-cycle defined in its specification for updating the state of activations and the jobs to execute them, when requested. The instance also provides change notification to the agenda about activation state changes.
  Author:
    Abel Hegedus

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ActivationState` | `activationStateTransition(Activation<EventAtom> activation, EventType event)` Performs the state transition on the given activation in response to the specified event using the life-cycle defined in the rule specification.
    `boolean` | `addActivationNotificationListener(IActivationNotificationListener listener, boolean fireNow)` Delegate method for `ActivationNotificationProvider.addActivationNotificationListener(org.eclipse.incquery.runtime.evm.notification.IActivationNotificationListener, boolean)`.
    `Activation<EventAtom>` | `createActivation(EventAtom atom)`
    `void` | `fire(Activation<EventAtom> activation, Context context)` Fires the given activation using the supplied context.
    `com.google.common.collect.Table<ActivationState,EventAtom,Activation<EventAtom>>` | `getActivations()`
    `java.util.Collection<Activation<EventAtom>>` | `getActivations(ActivationState state)`
    `java.util.Collection<Activation<EventAtom>>` | `getAllActivations()`
    `EventFilter<? super EventAtom>` | `getFilter()`
    `ActivationLifeCycle` | `getLifeCycle()`
    `RuleSpecification<EventAtom>` | `getSpecification()`
    `boolean` | `removeActivationNotificationListener(IActivationNotificationListener listener)` Delegate method for `ActivationNotificationProvider.removeActivationNotificationListener(org.eclipse.incquery.runtime.evm.notification.IActivationNotificationListener)`.
    `void` | `setHandler(EventHandler<EventAtom> handler)`
    `java.lang.String` | `toString()`

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

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

- - ### Method Detail

    - #### setHandler

          public void setHandler(EventHandler<EventAtom> handler)

    - #### createActivation

          public Activation<EventAtom> createActivation(EventAtom atom)

    - #### fire

          public void fire(Activation<EventAtom> activation,
                           Context context)

      Fires the given activation using the supplied context. Delegates to the doFire method
      Parameters:
        `activation` -
        `context` -

    - #### activationStateTransition

          public ActivationState activationStateTransition(Activation<EventAtom> activation,
                                                           EventType event)

      Performs the state transition on the given activation in response to the specified event using the life-cycle defined in the rule specification. If there is a transition defined for the current state and the event, the activation state is updated. Finally, an activation change notification is sent to listeners and the new state is returned.
      Parameters:
        `activation` -
        `event` -
      Returns:
        the state of the activation after the transition

    - #### addActivationNotificationListener

          public boolean addActivationNotificationListener(IActivationNotificationListener listener,
                                                           boolean fireNow)

      Delegate method for `ActivationNotificationProvider.addActivationNotificationListener(org.eclipse.incquery.runtime.evm.notification.IActivationNotificationListener, boolean)`.
      Specified by:
        `addActivationNotificationListener` in interface `IActivationNotificationProvider`
      Parameters:
        `listener` -
        `fireNow` -

    - #### removeActivationNotificationListener

          public boolean removeActivationNotificationListener(IActivationNotificationListener listener)

      Delegate method for `ActivationNotificationProvider.removeActivationNotificationListener(org.eclipse.incquery.runtime.evm.notification.IActivationNotificationListener)`.
      Specified by:
        `removeActivationNotificationListener` in interface `IActivationNotificationProvider`
      Parameters:
        `listener` -

    - #### getSpecification

          public RuleSpecification<EventAtom> getSpecification()

      Returns:
        the specification

    - #### getFilter

          public EventFilter<? super EventAtom> getFilter()

    - #### getLifeCycle

          public ActivationLifeCycle getLifeCycle()

    - #### getActivations

          public com.google.common.collect.Table<ActivationState,EventAtom,Activation<EventAtom>> getActivations()

      Returns:
        the live table of activations

    - #### getAllActivations

          public java.util.Collection<Activation<EventAtom>> getAllActivations()

      Returns:
        the live set of activations

    - #### getActivations

          public java.util.Collection<Activation<EventAtom>> getActivations(ActivationState state)

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

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`