Package org.somda.sdc.common.event
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
Subscribeannotation:public class Foo { @Subscribe void doSomethingWith(Bar payload) { // ... } }If an instance of Foo is registered for an event bus andEventBus.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 Summary
Constructors Modifier Constructor Description protectedAbstractEventMessage(T payload)
-