All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rinde.sim.event.EventAPI Maven / Gradle / Ivy

There is a newer version: 4.4.6
Show newest version
/**
 * 
 */
package rinde.sim.event;

import java.util.Set;

/**
 * The Event API provides an interface which can be presented to objects which
 * have an interest to receive events of a certain object.
 * 
 * @author Rinde van Lon ([email protected])
 * 
 */
public interface EventAPI {

  /**
   * Adds the specified listener. From now on, the specified listener will be
   * notified of events with one of the eventTypes. If
   * eventTypes is not specified, the listener will be notified of
   * all events.
   * @param listener The listener, may not be null.
   * @param eventTypes The {@link Event} types, each type but be a type that is
   *          supported by this EventDispatcher. May not be null. If no
   *          eventTypes are specified, the listener will be notified of
   *          all events.
   */
  void addListener(Listener listener, Enum... eventTypes);

  /**
   * Adds the specified listener. From now on, the specified listener will be
   * notified of events with one of the eventTypes. If
   * eventTypes is empty, the listener will be notified of
   * no events.
   * @param listener The listener, may not be null.
   * @param eventTypes The {@link Event} types, each type but be a type that is
   *          supported by this EventDispatcher. May not be null. If no
   *          eventTypes are specified, the listener will be notified of
   *          no events.
   */
  void addListener(Listener listener, Set> eventTypes);

  /**
   * Removes the specified listener with the specified event types. From now on,
   * listener will no longer be notified of new {@link Event} s
   * with any of eventTypes. If eventTypes undefined
   * the listener will be completely removed.
   * @param listener The {@link Listener} to remove.
   * @param eventTypes The event types.
   */
  void removeListener(Listener listener, Enum... eventTypes);

  /**
   * Removes the specified listener with the specified event types. From now on,
   * listener will no longer be notified of new {@link Event} s
   * with any of eventTypes. If eventTypes is empty
   * the listener will be completely removed.
   * @param listener The {@link Listener} to remove.
   * @param eventTypes The event types.
   */
  void removeListener(Listener listener, Set> eventTypes);

  /**
   * Checks if the specified listener is registered as listening to
   * eventType.
   * @param listener The listener to check.
   * @param eventType The type of event.
   * @return true if the listener is listening to
   *         eventType, false otherwise.
   */
  boolean containsListener(Listener listener, Enum eventType);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy