org.eclipse.viatra.integration.mwe2.mwe2impl

## Class Topic

- java.lang.Object
- - org.eclipse.viatra.integration.mwe2.mwe2impl.Topic

- All Implemented Interfaces:
    ITopic

      public class Topic
      extends java.lang.Object
      implements ITopic

  Topics contain subscribing transformation steps and messages sent to these subscribers. Supports the addition of new subscribers and messages. To remove processed messages, transformation steps have to call the removeMessage method, this way ensuring that no message gets lost due a failure during processing This implementation can be used with most of the workflows that can be described using this library.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `name`
    `protected java.util.Map<ITransformationStep,java.util.List<IMessage<?>>>` | `subscriberMap`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Topic(java.lang.String name)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addMessage(IMessage<?> message)` Adds the provided message to this topic
    `void` | `addSubscriber(ITransformationStep subscriber)` Adds a new subscriber to this topic
    `java.util.List<IMessage<?>>` | `getMessages(ITransformationStep sub)` Returns every message sent to the given subscriber
    `java.lang.String` | `getName()`
    `java.util.List<ITransformationStep>` | `getSubscribers()` Returns the subscribers of this topic
    `void` | `removeMessage(IMessage<?> message)` Removes the given message from every subscriber
    `void` | `removeMessage(IMessage<?> message, ITransformationStep sub)` Removes the message from the specified step.
    `void` | `setName(java.lang.String name)`

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

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

- - ### Field Detail

    - #### name

          protected java.lang.String name

    - #### subscriberMap

          protected java.util.Map<ITransformationStep,java.util.List<IMessage<?>>> subscriberMap

  - ### Constructor Detail

    - #### Topic

          public Topic(java.lang.String name)

  - ### Method Detail

    - #### addMessage

          public void addMessage(IMessage<?> message)

      Description copied from interface: `ITopic`
      Adds the provided message to this topic
      Specified by:
        `addMessage` in interface `ITopic`
      Parameters:
        `message` - Message added to this topic

    - #### addSubscriber

          public void addSubscriber(ITransformationStep subscriber)

      Description copied from interface: `ITopic`
      Adds a new subscriber to this topic
      Specified by:
        `addSubscriber` in interface `ITopic`

    - #### getMessages

          public java.util.List<IMessage<?>> getMessages(ITransformationStep sub)

      Description copied from interface: `ITopic`
      Returns every message sent to the given subscriber
      Specified by:
        `getMessages` in interface `ITopic`

    - #### getName

          public java.lang.String getName()

      Specified by:
        `getName` in interface `ITopic`

    - #### getSubscribers

          public java.util.List<ITransformationStep> getSubscribers()

      Description copied from interface: `ITopic`
      Returns the subscribers of this topic
      Specified by:
        `getSubscribers` in interface `ITopic`

    - #### setName

          public void setName(java.lang.String name)

      Specified by:
        `setName` in interface `ITopic`

    - #### removeMessage

          public void removeMessage(IMessage<?> message)

      Description copied from interface: `ITopic`
      Removes the given message from every subscriber
      Specified by:
        `removeMessage` in interface `ITopic`

    - #### removeMessage

          public void removeMessage(IMessage<?> message,
                                    ITransformationStep sub)

      Removes the message from the specified step. This is used to inform the topic that the message processing was successful and the message is no longer needed.
      Specified by:
        `removeMessage` in interface `ITopic`
      Parameters:
        `message` - Message to be removed
        `sub` - Specified subscriber