Class SimulationStateEvent

java.lang.Object
java.util.EventObject
org.bzdev.devqsim.SimulationStateEvent
All Implemented Interfaces:
Serializable

public class SimulationStateEvent extends EventObject
Event indicating a change in the state of a simulation or one of its objects.
See Also:
  • Constructor Details

    • SimulationStateEvent

      public SimulationStateEvent(Object source, Simulation sim, Enum<?> type, Object origin, Object parameter)
      Constructor.
      Parameters:
      source - the event source
      sim - the simulation
      type - the type of the event.
      origin - the object that originated the event
      parameter - an event parameter (usage depends on the type)
    • SimulationStateEvent

      public SimulationStateEvent(Object source, Simulation sim, Object server, Enum<?> type, Object origin, Object parameter)
      Constructor.
      Parameters:
      source - the event source
      sim - the simulation
      server - the server (valid for a queue server)
      type - the type of the event.
      origin - the object that originated the event
      parameter - an event parameter (usage depends on the type)
  • Method Details

    • getSource

      public <T> T getSource(Class<T> clazz)
      Get the source of the event. The source is the object that directly caused the event to be sent
      Type Parameters:
      T - the type for the class specified by the argument
      Parameters:
      clazz - the type that will be returned, which must match that for the source of this event
      Returns:
      the source of the event
    • getType

      public <T extends Enum<T>> T getType(Class<T> clazz)
      Get the type of the event.
      Type Parameters:
      T - the type for the class specified by the argument
      Parameters:
      clazz - the class of the type, which must be an enum
      Returns:
      the type of the event; null if the event does not have the specified type
    • getSimulation

      public Simulation getSimulation()
      Get the simulation associated with the event.
      Returns:
      the simulation
    • getOrigin

      public Object getOrigin()
      Get an event's origin. The origin is an object that was responsible for the event being generated by the source. It's meaning depends on the type of event.
      Returns:
      the origin
    • getOrigin

      public <T> T getOrigin(Class<T> clazz)
      Get an event's origin as a specific type. The origin is an object that was responsible for the event being generated by the source. It's meaning depends on the type of event.
      Type Parameters:
      T - the type for the class specified by the argument
      Parameters:
      clazz - the class (or a superclass) of the origin
      Returns:
      the origin
    • getParameter

      public Object getParameter()
      Get the event parameter.
      Returns:
      the parameter.
    • getServer

      public Object getServer()
      Get the server associated with an event. A server in this case is an object that implements a server used by a server queue in the simulation.
      Returns:
      the server
    • getParameter

      public <T> T getParameter(Class<T> clazz)
      Get the event parameter, cast to a specific type
      Type Parameters:
      T - the type for the class specified by the argument
      Parameters:
      clazz - the class (or a superclass) of the parameter.
      Returns:
      the parameter.