Add simple data listeners
[mdsal.git] / binding / mdsal-binding-api / src / main / java / org / opendaylight / mdsal / binding / api / DataChangeListener.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. 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 com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.Nullable;
12 import org.opendaylight.yangtools.yang.binding.DataObject;
13
14 /**
15  * Interface implemented by classes interested in receiving data changes.
16  * It provides a comparison on before-value and after-value.
17  */
18 @Beta
19 @FunctionalInterface
20 public interface DataChangeListener<T extends DataObject> {
21     /**
22      * Invoked when there was data change for the supplied path, which was used
23      * to register the listener.
24      *
25      * <p>
26      * Note: When invoking the method {@link DataTreeChangeListener#onInitialData} initial data == null, null.
27      * @param previousValue data before.
28      * @param currentValue data after.
29      */
30     void dataChanged(@Nullable T previousValue, @Nullable T currentValue);
31 }