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

com.github.rinde.rinsim.event.EventAPI Maven / Gradle / Ivy

There is a newer version: 4.4.6
Show newest version
/*
 * Copyright (C) 2011-2018 Rinde R.S. van Lon
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.rinde.rinsim.event;

/**
 * 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, Iterable> 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,
      Iterable> 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