Class AbstractEventMessage<T>

java.lang.Object
org.somda.sdc.common.event.AbstractEventMessage<T>
Type Parameters:
T - payload type.
All Implemented Interfaces:
EventMessage

public abstract class AbstractEventMessage<T> extends Object implements EventMessage
Simple message container to ease use with EventBus.

Google Guava's event bus library dispatches events based on function parametrization. Given a class with a Subscribe annotation:

 public class Foo {
     @Subscribe
     void doSomethingWith(Bar payload) {
         // ...
     }
 }
 
If an instance of Foo is registered for an event bus and EventBus.post(Object) with a Bar instance is invoked, Guava knows which function to call by looking at the parameters of all Subsribe-annotated functions.

The abstract event message helps in strong-typing EventBus-accepted functions and encapsulates a default payload that is requestable by using the getPayload() method.

  • Constructor Details

    • AbstractEventMessage

      protected AbstractEventMessage(T payload)
  • Method Details

    • getPayload

      public T getPayload()