Add DOMInstanceNotificationService
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMInstanceNotificationService.java
1 /*
2  * Copyright (c) 2021 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.dom.api;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.concurrent.Executor;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.opendaylight.yangtools.concepts.Registration;
15 import org.opendaylight.yangtools.yang.common.QName;
16
17 /**
18  * A {@link DOMService} providing access to subscription to YANG 1.1 instance notifications.
19  */
20 @Beta
21 @NonNullByDefault
22 public interface DOMInstanceNotificationService extends DOMService {
23     /**
24      * Register a {@link DOMInstanceNotificationListener} for a particular {@code path} and notification {@code type}.
25      *
26      * @param path Instance notification's parent path, must not be empty, but may be a wildcard identifier.
27      * @param type Notification type, i.e. its schema node QName
28      * @param listener Listener to deliver notifications to
29      * @param executor Executor to use for invoking
30      * @return Listener's registration object
31      * @throws NullPointerException if any of the arguments is null
32      * @throws IllegalArgumentException if the {@code path} is empty or if the combination of {@code path} and
33      *                                  {@code type} does not identify an instance notification
34      */
35     Registration registerNotificationListener(DOMDataTreeIdentifier path, QName type,
36         DOMInstanceNotificationListener listener, Executor executor);
37
38     /**
39      * Register a {@link DOMInstanceNotificationListener} for a particular {@code path} and notification {@code type}.
40      * This method is a convenience equivalent to
41      * {@code registerNotificationListener(path, type, listener, MoreExecutors.directExecutor())}.
42      *
43      * @param path Instance notification's parent path, must not be empty, but may be a wildcard identifier.
44      * @param type Notification type, i.e. its schema node QName
45      * @param listener Listener to deliver notifications to
46      * @return Listener's registration object
47      * @throws NullPointerException if any of the arguments is null
48      * @throws IllegalArgumentException if the {@code path} is empty or if the combination of {@code path} and
49      *                                  {@code type} does not identify an instance notification
50      */
51     default Registration registerNotificationListener(final DOMDataTreeIdentifier path, final QName type,
52             final DOMInstanceNotificationListener listener) {
53         return registerNotificationListener(path, type, listener, MoreExecutors.directExecutor());
54     }
55 }