6d6ea17a3564508b131c398bccd99541a84dc5df
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / md / sal / 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.controller.md.sal.binding.api;
9
10 import java.util.Collection;
11 import java.util.EventListener;
12 import javax.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. This interface differs from {@link DataChangeListener}
18  * in that it provides a cursor-based view of the change, which has potentially
19  * lower overhead and allow more flexible consumption of change event.
20  *
21  * <p>
22  * Note: this interface enables notifications only at the leader of the data store, if clustered. If you want
23  * notifications on all instances in a cluster, use the {@link ClusteredDataTreeChangeListener}.
24  */
25 public interface DataTreeChangeListener<T extends DataObject> extends EventListener {
26     /**
27      * Invoked when there was data change for the supplied path, which was used
28      * to register this listener.
29      *
30      * <p>
31      * This method may be also invoked during registration of the listener if
32      * there is any pre-existing data in the conceptual data tree for supplied
33      * path. This initial event will contain all pre-existing data as created.
34      *
35      * <p>
36      * A data change event may be triggered spuriously, e.g. such that data before
37      * and after compare as equal. Implementations of this interface are expected
38      * to recover from such events. Event producers are expected to exert reasonable
39      * effort to suppress such events.
40      *
41      * <p>
42      * In other words, it is completely acceptable to observe
43      * a {@link DataObjectModification}, while the state observed before and
44      * after- data items compare as equal.
45      *
46      * @param changes Collection of change events, may not be null or empty.
47      */
48     void onDataTreeChanged(@Nonnull Collection<DataTreeModification<T>> changes);
49 }