This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/common/src/main/java/envoy/event/Event.java

50 lines
1.2 KiB
Java

package envoy.event;
import java.io.Serializable;
/**
* 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
*/
public abstract class Event<T> implements Serializable {
protected final T value;
private static final long serialVersionUID = 0L;
protected Event(T value) { this.value = value; }
/**
* @return the data associated with this event
*/
public T get() { return value; }
@Override
public String toString() { return String.format("%s[value=%s]", this.getClass().getSimpleName(), value); }
/**
* 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 = 0L;
protected Valueless() { super(null); }
@Override
public String toString() { return this.getClass().getSimpleName(); }
}
}