3d9fc0cfb04f3f07cb9d8da8bb01794d138a789f
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMNotificationPublishDemandExtension.java
1 /*
2  * Copyright (c) 2015 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 com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableSet;
12 import java.util.EventListener;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.opendaylight.yangtools.concepts.Registration;
15 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
16
17 /**
18  * A {@link DOMNotificationPublishService.Extension} providing a view into which {@link DOMNotification}s the extended
19  * {@link DOMNotificationPublishService} is interested in receiving. This is typically driven by listener registrations
20  * in the {@link DOMNotificationService} consuming published notifications.
21  */
22 @Beta
23 @NonNullByDefault
24 public interface DOMNotificationPublishDemandExtension extends DOMNotificationPublishService.Extension {
25     /**
26      * Register a new {@link DemandListener}.
27      *
28      * @param listener the listener to register
29      * @return A {@link Registration}
30      * @throws NullPointerException if {@code listener} is {@code null}
31      */
32     Registration registerDemandListener(DemandListener listener);
33
34     /**
35      * Listener for changes in demand for {@link DOMNotification} types. Changes are communnicated via
36      * {@link #onDemandUpdated(ImmutableSet)}, which reports the delta between last reported and current state.
37      */
38     interface DemandListener extends EventListener {
39         /**
40          * Update the view of what {@link DOMNotification}s are in demand.
41          *
42          * @param neededTypes currently-needed notification types
43          */
44         void onDemandUpdated(ImmutableSet<Absolute> neededTypes);
45     }
46 }