Class 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 the Event 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 the getSource() 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
    • Field Summary

      • Fields inherited from class java.util.EventObject

        source
    • 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 java.util.EventObject

        toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • GenericEvent

        public GenericEvent​(S source)
    • Method Detail

      • getSource

        public S getSource()
        Overrides:
        getSource in class java.util.EventObject