Refactor DOM{Action,Rpc}Implementation
[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
23         extends DOMService<DOMInstanceNotificationService, DOMInstanceNotificationService.Extension> {
24     /**
25      * Marker interface for an extension to {@link DOMInstanceNotificationService}.
26      */
27     interface Extension extends DOMService.Extension<DOMInstanceNotificationService, Extension> {
28         // Marker interface
29     }
30
31     /**
32      * Register a {@link DOMInstanceNotificationListener} for a particular {@code path} and notification {@code type}.
33      *
34      * @param path Instance notification's parent path, must not be empty, but may be a wildcard identifier.
35      * @param type Notification type, i.e. its schema node QName
36      * @param listener Listener to deliver notifications to
37      * @param executor Executor to use for invoking
38      * @return Listener's registration object
39      * @throws NullPointerException if any of the arguments is null
40      * @throws IllegalArgumentException if the {@code path} is empty or if the combination of {@code path} and
41      *                                  {@code type} does not identify an instance notification
42      */
43     Registration registerNotificationListener(DOMDataTreeIdentifier path, QName type,
44         DOMInstanceNotificationListener listener, Executor executor);
45
46     /**
47      * Register a {@link DOMInstanceNotificationListener} for a particular {@code path} and notification {@code type}.
48      * This method is a convenience equivalent to
49      * {@code registerNotificationListener(path, type, listener, MoreExecutors.directExecutor())}.
50      *
51      * @param path Instance notification's parent path, must not be empty, but may be a wildcard identifier.
52      * @param type Notification type, i.e. its schema node QName
53      * @param listener Listener to deliver notifications to
54      * @return Listener's registration object
55      * @throws NullPointerException if any of the arguments is null
56      * @throws IllegalArgumentException if the {@code path} is empty or if the combination of {@code path} and
57      *                                  {@code type} does not identify an instance notification
58      */
59     default Registration registerNotificationListener(final DOMDataTreeIdentifier path, final QName type,
60             final DOMInstanceNotificationListener listener) {
61         return registerNotificationListener(path, type, listener, MoreExecutors.directExecutor());
62     }
63 }