import java.util.Collection;
import java.util.EventListener;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.binding.DataObject;
/**
* path. This initial event will contain all pre-existing data as created.
*
* <p>
+ * Note: If there is no pre-existing data, the method {@link #onInitialData} will be invoked.
+ *
+ * <p>
* A data change event may be triggered spuriously, e.g. such that data before
* and after compare as equal. Implementations of this interface are expected
* to recover from such events. Event producers are expected to exert reasonable
*
* @param changes Collection of change events, may not be null or empty.
*/
- void onDataTreeChanged(@Nonnull Collection<DataTreeModification<T>> changes);
+ void onDataTreeChanged(@NonNull Collection<DataTreeModification<T>> changes);
+
+ /**
+ * Invoked only once during registration of the listener if there was no data in the conceptual data tree
+ * for the supplied path, which was used to register this listener, and after this
+ * {@link #onDataTreeChanged(Collection)} would always be invoked for data changes.
+ *
+ * <p>
+ * Default implementation does nothing and is appropriate for users who do not care about ascertaining
+ * initial state.
+ */
+ default void onInitialData() {
+ //no-op
+ }
}