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