Package rea.events

Class EventBroadcast<T extends UpdateEvent>

java.lang.Object
rea.events.EventBroadcast<T>
Type Parameters:
T - the type of event that can be listened to.

public class EventBroadcast<T extends UpdateEvent> extends Object
Event broadcast to registered listeners. Listeners can be added and removed using the addListener(rea.events.UpdateListener<T>) and removeListener(rea.events.UpdateListener<T>) methods. Listeners are automatically removed if they throw an exception. Events are broadcast to all listeners using the broadcast(T) method.
Author:
José Paulo Leal jpleal@fc.up.pt
  • Field Details

  • Constructor Details

    • EventBroadcast

      public EventBroadcast()
      Create an instance of this class. No particular initializations are performed.
  • Method Details

    • addListener

      public void addListener(UpdateListener<T> listener)
      Add a listener to the list of listeners.
      Parameters:
      listener - the listener to add.
    • removeListener

      public void removeListener(UpdateListener<T> listener)
      Remove a listener from the list of listeners.
      Parameters:
      listener - the listener to remove.
    • getListeners

      public Set<UpdateListener<T>> getListeners()
      Get all the currently registered listeners. Listeners are automatically removed if they throw an exception.
      Returns:
      set of listeners.
    • broadcast

      public void broadcast(T event)
      Broadcast an event to all listeners. If the events is not handled by a listener, the listener is removed.
      Parameters:
      event - the event to broadcast.