]> git.basschouten.com Git - openhab-addons.git/blob
03288e89eabc7ad67cceef00454d792e861326cf
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.bticinosmarther.internal.config;
14
15 import java.util.ArrayList;
16 import java.util.Collections;
17 import java.util.List;
18
19 /**
20  * The {@code SmartherBridgeConfiguration} class defines the internal configuration of a {@code SmartherBridgeHandler}
21  * instance.
22  *
23  * @author Fabio Possieri - Initial contribution
24  */
25 public class SmartherBridgeConfiguration {
26
27     private String subscriptionKey;
28     private String clientId;
29     private String clientSecret;
30     private boolean useNotifications;
31     private int statusRefreshPeriod;
32     private String notificationUrl;
33     private List<String> notifications;
34
35     /**
36      * Returns the Legrand/Bticino product subscription key.
37      *
38      * @return a string containing the subscription key
39      */
40     public String getSubscriptionKey() {
41         return subscriptionKey;
42     }
43
44     /**
45      * Sets the Legrand/Bticino product subscription key.
46      *
47      * @param subscriptionKey
48      *            the new product subscription key
49      */
50     public void setSubscriptionKey(String subscriptionKey) {
51         this.subscriptionKey = subscriptionKey;
52     }
53
54     /**
55      * Returns the Legrand/Bticino user account client identifier.
56      *
57      * @return a string containing the client identifier
58      */
59     public String getClientId() {
60         return clientId;
61     }
62
63     /**
64      * Sets the Legrand/Bticino user account client identifier.
65      *
66      * @param clientId
67      *            the new client identifier
68      */
69     public void setClientId(String clientId) {
70         this.clientId = clientId;
71     }
72
73     /**
74      * Returns the Legrand/Bticino user account client secret.
75      *
76      * @return a string containing the client secret
77      */
78     public String getClientSecret() {
79         return clientSecret;
80     }
81
82     /**
83      * Sets the Legrand/Bticino user account client secret.
84      *
85      * @param clientSecret
86      *            the new client secret
87      */
88     public void setClientSecret(String clientSecret) {
89         this.clientSecret = clientSecret;
90     }
91
92     /**
93      * Tells whether the Bridge subscribes to receive modules status notifications.
94      *
95      * @return {@code true} if the notifications are turned on, {@code false} otherwise
96      */
97     public boolean isUseNotifications() {
98         return useNotifications;
99     }
100
101     /**
102      * Sets whether the Bridge subscribes to receive modules status notifications.
103      *
104      * @param useNotifications
105      *            {@code true} if the notifications are turned on, {@code false} otherwise
106      */
107     public void setUseNotifications(boolean useNotifications) {
108         this.useNotifications = useNotifications;
109     }
110
111     /**
112      * Returns the Bridge status refresh period (in minutes).
113      *
114      * @return the Bridge status refresh period
115      */
116     public int getStatusRefreshPeriod() {
117         return statusRefreshPeriod;
118     }
119
120     /**
121      * Sets the Bridge status refresh period (in minutes).
122      *
123      * @param statusRefreshPeriod
124      *            the new Bridge status refresh period
125      */
126     public void setStatusRefreshPeriod(int statusRefreshPeriod) {
127         this.statusRefreshPeriod = statusRefreshPeriod;
128     }
129
130     /**
131      * Returns the notification url for this Bridge.
132      *
133      * @return a string containing the notification url
134      */
135     public String getNotificationUrl() {
136         return notificationUrl;
137     }
138
139     /**
140      * Sets the notification url for this Bridge.
141      *
142      * @param notificationUrl
143      *            the new notification url
144      */
145     public void setNotificationUrl(String notificationUrl) {
146         this.notificationUrl = notificationUrl;
147     }
148
149     /**
150      * Adds a notification identifier to the Bridge notifications list.
151      *
152      * @param notificationId
153      *            the notification identifier to add
154      *
155      * @return the new Bridge notifications list
156      */
157     public List<String> addNotification(String notificationId) {
158         if (notifications == null) {
159             notifications = new ArrayList<>();
160         }
161         if (!notifications.contains(notificationId)) {
162             notifications.add(notificationId);
163         }
164         return notifications;
165     }
166
167     /**
168      * Removes a notification identifier from the Bridge notifications list.
169      *
170      * @param notificationId
171      *            the notification identifier to remove
172      *
173      * @return the new Bridge notifications list
174      */
175     public List<String> removeNotification(String notificationId) {
176         if (notifications != null) {
177             notifications.remove(notificationId);
178         }
179         return notifications;
180     }
181
182     /**
183      * Returns the current Bridge notifications list.
184      *
185      * @return the current Bridge notifications list
186      */
187     public List<String> getNotifications() {
188         return (notifications != null) ? notifications : Collections.emptyList();
189     }
190
191     /**
192      * Sets a new Bridge notifications list.
193      *
194      * @param notifications
195      *            the new notifications list to set
196      */
197     public void setNotifications(List<String> notifications) {
198         this.notifications = notifications;
199     }
200 }