f4b6a0100bbb7b8752600ad37dca71781b557c72
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / streams / listeners / BaseListenerInterface.java
1 /*
2  * Copyright (c) 2016 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.restconf.nb.rfc8040.streams.listeners;
9
10 import java.util.Set;
11 import org.opendaylight.restconf.nb.rfc8040.streams.StreamSessionHandler;
12
13 /**
14  * Base interface for both listeners({@link ListenerAdapter}, {@link NotificationListenerAdapter}).
15  */
16 public interface BaseListenerInterface extends AutoCloseable {
17
18     /**
19      * Return all subscribers of listener.
20      *
21      * @return Set of all subscribers.
22      */
23     Set<StreamSessionHandler> getSubscribers();
24
25     /**
26      * Checks if exists at least one {@link StreamSessionHandler} subscriber.
27      *
28      * @return {@code true} if exist at least one {@link StreamSessionHandler} subscriber, {@code false} otherwise.
29      */
30     boolean hasSubscribers();
31
32     /**
33      * Get name of stream.
34      *
35      * @return Stream name.
36      */
37     String getStreamName();
38
39     /**
40      * Get output type.
41      *
42      * @return Output type (JSON or XML).
43      */
44     String getOutputType();
45
46     /**
47      * Registers {@link StreamSessionHandler} subscriber.
48      *
49      * @param subscriber SSE or WS session handler.
50      */
51     void addSubscriber(StreamSessionHandler subscriber);
52
53     /**
54      * Removes {@link StreamSessionHandler} subscriber.
55      *
56      * @param subscriber SSE or WS session handler.
57      */
58     void removeSubscriber(StreamSessionHandler subscriber);
59 }