Source code
Description: source: package: org.apache.commons.configuration2.event, interface: EventSource

    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *     https://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.configuration2.event;
    018
    019/**
    020 * <p>
    021 * An interface for configuration implementations which support registration of event listeners.
    022 * </p>
    023 * <p>
    024 * Through the methods provided by this interface it is possible to register and remove listeners for different events
    025 * supported by this library. The event type to be handled by a listener must be provided; the specified event listener
    026 * must be compatible with this event type. By using generic type parameters, the compiler can check this.
    027 * </p>
    028 *
    029 * @since 2.0
    030 */
    031public interface EventSource {
    032
    033    /**
    034     * Adds an event listener for the specified event type. This listener is notified about events of this type and all its
    035     * sub types.
    036     *
    037     * @param eventType the event type (must not be <strong>null</strong>)
    038     * @param listener the listener to be registered (must not be <strong>null</strong>)
    039     * @param <T> the type of events processed by this listener
    040     * @throws IllegalArgumentException if a required parameter is <strong>null</strong>
    041     */
    042    <T extends Event> void addEventListener(EventType<T> eventType, EventListener<? super T> listener);
    043
    044    /**
    045     * Removes the event listener registration for the given event type and listener. An event listener instance may be
    046     * registered multiple times for different event types. Therefore, when removing a listener the event type of the
    047     * registration in question has to be specified. The return value indicates whether a registration was removed. A value
    048     * of <strong>false</strong> means that no such combination of event type and listener was found.
    049     *
    050     * @param eventType the event type
    051     * @param listener the event listener to be removed
    052     * @param <T> the type of events processed by this listener
    053     * @return a flag whether a listener registration was removed
    054     */
    055    <T extends Event> boolean removeEventListener(EventType<T> eventType, EventListener<? super T> listener);
    056}