2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.dom.api;
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;
17 * A {@link DOMService} which allows its users to subscribe to receive top-level (YANG 1.0) {@link DOMNotification}s.
19 public interface DOMNotificationService extends DOMService {
21 * Register a {@link DOMNotificationListener} to receive a set of notifications. As with other
22 * ListenerRegistration-based interfaces, registering an instance multiple times results in
23 * notifications being delivered for each registration.
25 * @param listener Notification instance to register
26 * @param types Notification types which should be delivered to the listener. Duplicate entries
27 * are processed only once, null entries are ignored.
28 * @return Registration handle. Invoking {@link ListenerRegistration#close()} will stop the
29 * delivery of notifications to the listener
30 * @throws IllegalArgumentException if types is empty or contains an invalid element, such as
31 * null or a schema node identifier which does not represent a valid {@link DOMNotification} type.
32 * @throws NullPointerException if either of the arguments is null
34 <T extends DOMNotificationListener> ListenerRegistration<T>
35 registerNotificationListener(@NonNull T listener, @NonNull Collection<Absolute> types);
38 * Register a {@link DOMNotificationListener} to receive a set of notifications. As with other
39 * ListenerRegistration-based interfaces, registering an instance multiple times results in
40 * notifications being delivered for each registration.
42 * @param listener Notification instance to register
43 * @param types Notification types which should be delivered to the listener. Duplicate entries
44 * are processed only once, null entries are ignored.
45 * @return Registration handle. Invoking {@link ListenerRegistration#close()} will stop the
46 * delivery of notifications to the listener
47 * @throws IllegalArgumentException if types is empty or contains an invalid element, such as
48 * null or a schema node identifier which does not represent a valid {@link DOMNotification} type.
49 * @throws NullPointerException if listener is null
51 default <T extends DOMNotificationListener> ListenerRegistration<T>
52 registerNotificationListener(@NonNull final T listener, final Absolute... types) {
53 return registerNotificationListener(listener, Arrays.asList(types));