Package io.microsphere.event
Class GenericEvent<S>
- java.lang.Object
-
- java.util.EventObject
-
- io.microsphere.event.Event
-
- io.microsphere.event.GenericEvent<S>
-
- Type Parameters:
S
- the type of the event source
- All Implemented Interfaces:
java.io.Serializable
public class GenericEvent<S> extends Event
A generic implementation of theEvent
class that allows for type-safe event handling.This class extends the base
Event
class and provides a way to carry an arbitrary source object associated with the event. The source can be accessed in a type-safe manner using thegetSource()
method.Example Usage
// Create a new GenericEvent with a String source GenericEvent
event = new GenericEvent<>("Hello, World!"); // Access the source with its original type String source = event.getSource(); // No casting needed // Get the timestamp when the event was created long timestamp = event.getTimestamp(); - Since:
- 1.0.0
- Author:
- Mercy
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GenericEvent(S source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description S
getSource()
-
Methods inherited from class io.microsphere.event.Event
getTimestamp
-
-