2019-12-29 09:53:48 +01:00
|
|
|
package envoy.event;
|
|
|
|
|
2020-01-28 17:50:09 +01:00
|
|
|
import java.io.Serializable;
|
|
|
|
|
2019-12-29 09:53:48 +01:00
|
|
|
/**
|
|
|
|
* Project: <strong>envoy-common</strong><br>
|
|
|
|
* File: <strong>Event.java</strong><br>
|
|
|
|
* Created: <strong>04.12.2019</strong><br>
|
|
|
|
*
|
|
|
|
* @author Kai S. K. Engelbart
|
|
|
|
* @param <T> the type of the Event
|
|
|
|
* @since Envoy v0.2-alpha
|
|
|
|
*/
|
2020-02-11 16:53:41 +01:00
|
|
|
public abstract class Event<T> implements Serializable {
|
|
|
|
|
|
|
|
protected final T value;
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 4673659457380399167L;
|
|
|
|
|
|
|
|
protected Event(T value) { this.value = value; }
|
2019-12-29 09:53:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the data associated with this event
|
|
|
|
*/
|
2020-02-11 16:53:41 +01:00
|
|
|
public T get() { return value; }
|
|
|
|
|
|
|
|
@Override
|
2020-02-12 05:58:40 +01:00
|
|
|
public String toString() { return String.format("%s[value=%s]", this.getClass().getSimpleName(), value); }
|
2020-02-11 16:53:41 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Serves as a super class for events that do not carry a value.<br>
|
|
|
|
* <br>
|
|
|
|
* Project: <strong>envoy-common</strong><br>
|
|
|
|
* File: <strong>Event.java</strong><br>
|
|
|
|
* Created: <strong>11 Feb 2020</strong><br>
|
|
|
|
*
|
|
|
|
* @author Kai S. K. Engelbart
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
|
|
|
public static abstract class Valueless extends Event<Void> {
|
|
|
|
|
|
|
|
private static final long serialVersionUID = -9019362144094097997L;
|
|
|
|
|
|
|
|
protected Valueless() { super(null); }
|
2020-02-12 22:15:42 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() { return this.getClass().getSimpleName(); }
|
2020-02-11 16:53:41 +01:00
|
|
|
}
|
2019-12-29 09:53:48 +01:00
|
|
|
}
|