Fix onDataTreeChanged() references
[mdsal.git] / binding / mdsal-binding-api / src / main / java / org / opendaylight / mdsal / binding / api / DataTreeChangeListener.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.api;
9
10 import java.util.Collection;
11 import java.util.EventListener;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.binding.DataObject;
14
15 /**
16  * Interface implemented by classes interested in receiving notifications about
17  * data tree changes. It provides a cursor-based view of the change, which has potentially
18  * lower overhead and allow more flexible consumption of change event.
19  */
20 public interface DataTreeChangeListener<T extends DataObject> extends EventListener {
21     /**
22      * Invoked when there was data change for the supplied path, which was used
23      * to register this listener.
24      *
25      * <p>
26      * This method may be also invoked during registration of the listener if
27      * there is any pre-existing data in the conceptual data tree for supplied
28      * path. This initial event will contain all pre-existing data as created.
29      *
30      * <p>
31      * Note: If there is no pre-existing data, the method {@link #onInitialData} will be invoked.
32      *
33      * <p>
34      * A data change event may be triggered spuriously, e.g. such that data before
35      * and after compare as equal. Implementations of this interface are expected
36      * to recover from such events. Event producers are expected to exert reasonable
37      * effort to suppress such events.
38      *
39      *<p>
40      * In other words, it is completely acceptable to observe
41      * a {@link DataObjectModification}, while the state observed before and
42      * after- data items compare as equal.
43      *
44      * @param changes Collection of change events, may not be null or empty.
45      */
46     void onDataTreeChanged(@NonNull Collection<DataTreeModification<T>> changes);
47
48     /**
49      * Invoked only once during registration of the listener if there was no data in the conceptual data tree
50      * for the supplied path, which was used to register this listener, and after this
51      * {@link #onDataTreeChanged(Collection)} would always be invoked for data changes.
52      *
53      * <p>
54      * Default implementation does nothing and is appropriate for users who do not care about ascertaining
55      * initial state.
56      */
57     default void onInitialData() {
58         //no-op
59     }
60 }