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 * https://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 * Definition of a generic event listener interface.
22 * </p>
23 * <p>
24 * This event listener interface is used throughout the <em>Commons Configuration</em> library for reacting on all kinds
25 * of supported events. The interface is pretty minimalistic, defining only a single {@code onEvent()} method. This
26 * simplifies the implementation of custom event listeners and also supports the new language features introduced with
27 * Java 8 ({@code EventListener} is a functional interface and thus can be represented by a Lambda expression).
28 * </p>
29 *
30 * @param <T> the type of events this listener can process
31 * @since 2.0
32 */
33 public interface EventListener<T extends Event> {
34 /**
35 * Notifies this event listener about the arrival of a new event. Typically, event listeners are registered at an event
36 * source providing an {@link EventType}. This event type acts as a filter; all events matched by the filter are passed
37 * to the listener. The type parameters defined by the {@code EventType} class and this interface guarantee that the
38 * events delivered to the handler are compatible with the concrete method signature of {@code onEvent()}.
39 *
40 * @param event the event
41 */
42 void onEvent(T event);
43 }