Refactor DOM{Action,Rpc}Implementation
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMNotificationService.java
1 /*
2  * Copyright (c) 2014 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.mdsal.dom.api;
9
10 import java.util.Collection;
11 import java.util.List;
12 import java.util.Map;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.concepts.Registration;
15 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
16
17 /**
18  * A {@link DOMService} which allows its users to subscribe to receive top-level (YANG 1.0) {@link DOMNotification}s.
19  */
20 public interface DOMNotificationService extends DOMService<DOMNotificationService, DOMNotificationService.Extension> {
21     /**
22      * Marker interface for an extension to {@link DOMNotificationService}.
23      */
24     interface Extension extends DOMService.Extension<DOMNotificationService, Extension> {
25         // Marker interface
26     }
27
28     /**
29      * Register a {@link DOMNotificationListener} to receive a set of notifications. As with other
30      * {@link Registration}-based interfaces, registering an instance multiple times results in
31      * notifications being delivered for each registration.
32      *
33      * @param listener Notification instance to register
34      * @param types Notification types which should be delivered to the listener. Duplicate entries are processed only
35      *        once, null entries are ignored.
36      * @return Registration handle. Invoking {@link Registration#close()} will stop the delivery of notifications to the
37      *         listener
38      * @throws IllegalArgumentException if types is empty or contains an invalid element, such as {@code null} or a
39      *         schema node identifier which does not represent a valid {@link DOMNotification} type.
40      * @throws NullPointerException if either of the arguments is {@code null}
41      */
42     @NonNull Registration registerNotificationListener(@NonNull DOMNotificationListener listener,
43         @NonNull Collection<Absolute> types);
44
45     /**
46      * Register a {@link DOMNotificationListener} to receive a set of notifications. As with other
47      * {@link Registration}-based interfaces, registering an instance multiple times results in
48      * notifications being delivered for each registration.
49      *
50      * @param listener Notification instance to register
51      * @param types Notification types which should be delivered to the listener. Duplicate entries are processed only
52      *        once, null entries are ignored.
53      * @return Registration handle. Invoking {@link Registration#close()} will stop the delivery of notifications to the
54      *         listener
55      * @throws IllegalArgumentException if types is empty or contains an invalid element, such as {@code null} or a
56      *         schema node identifier which does not represent a valid {@link DOMNotification} type.
57      * @throws NullPointerException if listener is {@code null}
58      */
59     default @NonNull Registration registerNotificationListener(@NonNull final DOMNotificationListener listener,
60             final Absolute... types) {
61         return registerNotificationListener(listener, List.of(types));
62     }
63
64     /**
65      * Register a number of {@link DOMNotificationListener}s to receive some notification notifications. As with other
66      * {@link Registration}-based interfaces, registering an instance multiple times results in
67      * notifications being delivered for each registration.
68      *
69      * @param typeToListener Specification of which types to listen to with which listeners
70      * @throws NullPointerException if {@code typeToListener} is {@code null}
71      */
72     @NonNull Registration registerNotificationListeners(@NonNull Map<Absolute, DOMNotificationListener> typeToListener);
73 }