1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.configuration2.event; 18 19 /** 20 * <p> 21 * An interface for configuration implementations which support registration of event listeners. 22 * </p> 23 * <p> 24 * Through the methods provided by this interface it is possible to register and remove listeners for different events 25 * supported by this library. The event type to be handled by a listener must be provided; the specified event listener 26 * must be compatible with this event type. By using generic type parameters, the compiler can check this. 27 * </p> 28 * 29 * @since 2.0 30 */ 31 public interface EventSource { 32 /** 33 * Adds an event listener for the specified event type. This listener is notified about events of this type and all its 34 * sub types. 35 * 36 * @param eventType the event type (must not be <b>null</b>) 37 * @param listener the listener to be registered (must not be <b>null</b>) 38 * @param <T> the type of events processed by this listener 39 * @throws IllegalArgumentException if a required parameter is <b>null</b> 40 */ 41 <T extends Event> void addEventListener(EventType<T> eventType, EventListener<? super T> listener); 42 43 /** 44 * Removes the event listener registration for the given event type and listener. An event listener instance may be 45 * registered multiple times for different event types. Therefore, when removing a listener the event type of the 46 * registration in question has to be specified. The return value indicates whether a registration was removed. A value 47 * of <b>false</b> means that no such combination of event type and listener was found. 48 * 49 * @param eventType the event type 50 * @param listener the event listener to be removed 51 * @param <T> the type of events processed by this listener 52 * @return a flag whether a listener registration was removed 53 */ 54 <T extends Event> boolean removeEventListener(EventType<T> eventType, EventListener<? super T> listener); 55 }