2015-11-23 11:20:20 +01:00
|
|
|
package com.iluwatar.eda.event;
|
2015-11-23 00:02:58 +01:00
|
|
|
|
2015-12-01 23:30:01 +01:00
|
|
|
import com.iluwatar.eda.framework.EventDispatcher;
|
2015-11-23 11:20:20 +01:00
|
|
|
import com.iluwatar.eda.framework.Message;
|
2015-11-22 19:40:07 +01:00
|
|
|
|
2015-11-28 13:12:16 +01:00
|
|
|
/**
|
|
|
|
* The {@link Event} class serves as a base class for defining custom events happening with your
|
|
|
|
* system. In this example we have two types of events defined.
|
|
|
|
* <ul>
|
|
|
|
* <li>{@link UserCreatedEvent} - used when a user is created</li>
|
|
|
|
* <li>{@link UserUpdatedEvent} - used when a user is updated</li>
|
|
|
|
* </ul>
|
|
|
|
* Events can be distinguished using the {@link #getType() getType} method.
|
|
|
|
*/
|
2015-11-22 19:40:07 +01:00
|
|
|
public class Event implements Message {
|
2015-11-28 13:12:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the event type as a {@link Class} object
|
2015-12-01 23:30:01 +01:00
|
|
|
* In this example, this method is used by the {@link EventDispatcher} to
|
2015-12-01 23:33:26 +01:00
|
|
|
* dispatch events depending on their type.
|
2015-11-28 13:12:16 +01:00
|
|
|
*
|
|
|
|
* @return the Event type as a {@link Class}.
|
|
|
|
*/
|
|
|
|
public Class<? extends Message> getType() {
|
|
|
|
return getClass();
|
|
|
|
}
|
2015-11-22 19:40:07 +01:00
|
|
|
}
|