666f125b0e6856afa8df62537831d28ad8ea61b4
[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.Arrays;
11 import java.util.Collection;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.concepts.ListenerRegistration;
14 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
15
16 /**
17  * A {@link DOMService} which allows its users to subscribe to receive
18  * {@link DOMNotification}s.
19  */
20 public interface DOMNotificationService extends DOMService {
21     /**
22      * Register a {@link DOMNotificationListener} to receive a set of notifications. As with other
23      * ListenerRegistration-based interfaces, registering an instance multiple times results in
24      * notifications being delivered for each registration.
25      *
26      * @param listener Notification instance to register
27      * @param types Notification types which should be delivered to the listener. Duplicate entries
28      *        are processed only once, null entries are ignored.
29      * @return Registration handle. Invoking {@link ListenerRegistration#close()} will stop the
30      *         delivery of notifications to the listener
31      * @throws IllegalArgumentException if types is empty or contains an invalid element, such as
32      *         null or a schema node identifier which does not represent a valid {@link DOMNotification} type.
33      * @throws NullPointerException if either of the arguments is null
34      */
35     <T extends DOMNotificationListener> ListenerRegistration<T>
36             registerNotificationListener(@NonNull T listener, @NonNull Collection<Absolute> types);
37
38     /**
39      * Register a {@link DOMNotificationListener} to receive a set of notifications. As with other
40      * ListenerRegistration-based interfaces, registering an instance multiple times results in
41      * notifications being delivered for each registration.
42      *
43      * @param listener Notification instance to register
44      * @param types Notification types which should be delivered to the listener. Duplicate entries
45      *        are processed only once, null entries are ignored.
46      * @return Registration handle. Invoking {@link ListenerRegistration#close()} will stop the
47      *         delivery of notifications to the listener
48      * @throws IllegalArgumentException if types is empty or contains an invalid element, such as
49      *         null or a schema node identifier which does not represent a valid {@link DOMNotification} type.
50      * @throws NullPointerException if listener is null
51      */
52     default <T extends DOMNotificationListener> ListenerRegistration<T>
53             registerNotificationListener(@NonNull final T listener, final Absolute... types) {
54         return registerNotificationListener(listener, Arrays.asList(types));
55     }
56 }