2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.bticinosmarther.internal.config;
15 import java.util.ArrayList;
16 import java.util.Collections;
17 import java.util.List;
20 * The {@code SmartherBridgeConfiguration} class defines the internal configuration of a {@code SmartherBridgeHandler}
23 * @author Fabio Possieri - Initial contribution
25 public class SmartherBridgeConfiguration {
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;
36 * Returns the Legrand/Bticino product subscription key.
38 * @return a string containing the subscription key
40 public String getSubscriptionKey() {
41 return subscriptionKey;
45 * Sets the Legrand/Bticino product subscription key.
47 * @param subscriptionKey
48 * the new product subscription key
50 public void setSubscriptionKey(String subscriptionKey) {
51 this.subscriptionKey = subscriptionKey;
55 * Returns the Legrand/Bticino user account client identifier.
57 * @return a string containing the client identifier
59 public String getClientId() {
64 * Sets the Legrand/Bticino user account client identifier.
67 * the new client identifier
69 public void setClientId(String clientId) {
70 this.clientId = clientId;
74 * Returns the Legrand/Bticino user account client secret.
76 * @return a string containing the client secret
78 public String getClientSecret() {
83 * Sets the Legrand/Bticino user account client secret.
86 * the new client secret
88 public void setClientSecret(String clientSecret) {
89 this.clientSecret = clientSecret;
93 * Tells whether the Bridge subscribes to receive modules status notifications.
95 * @return {@code true} if the notifications are turned on, {@code false} otherwise
97 public boolean isUseNotifications() {
98 return useNotifications;
102 * Sets whether the Bridge subscribes to receive modules status notifications.
104 * @param useNotifications
105 * {@code true} if the notifications are turned on, {@code false} otherwise
107 public void setUseNotifications(boolean useNotifications) {
108 this.useNotifications = useNotifications;
112 * Returns the Bridge status refresh period (in minutes).
114 * @return the Bridge status refresh period
116 public int getStatusRefreshPeriod() {
117 return statusRefreshPeriod;
121 * Sets the Bridge status refresh period (in minutes).
123 * @param statusRefreshPeriod
124 * the new Bridge status refresh period
126 public void setStatusRefreshPeriod(int statusRefreshPeriod) {
127 this.statusRefreshPeriod = statusRefreshPeriod;
131 * Returns the notification url for this Bridge.
133 * @return a string containing the notification url
135 public String getNotificationUrl() {
136 return notificationUrl;
140 * Sets the notification url for this Bridge.
142 * @param notificationUrl
143 * the new notification url
145 public void setNotificationUrl(String notificationUrl) {
146 this.notificationUrl = notificationUrl;
150 * Adds a notification identifier to the Bridge notifications list.
152 * @param notificationId
153 * the notification identifier to add
155 * @return the new Bridge notifications list
157 public List<String> addNotification(String notificationId) {
158 if (notifications == null) {
159 notifications = new ArrayList<>();
161 if (!notifications.contains(notificationId)) {
162 notifications.add(notificationId);
164 return notifications;
168 * Removes a notification identifier from the Bridge notifications list.
170 * @param notificationId
171 * the notification identifier to remove
173 * @return the new Bridge notifications list
175 public List<String> removeNotification(String notificationId) {
176 if (notifications != null) {
177 notifications.remove(notificationId);
179 return notifications;
183 * Returns the current Bridge notifications list.
185 * @return the current Bridge notifications list
187 public List<String> getNotifications() {
188 return (notifications != null) ? notifications : Collections.emptyList();
192 * Sets a new Bridge notifications list.
194 * @param notifications
195 * the new notifications list to set
197 public void setNotifications(List<String> notifications) {
198 this.notifications = notifications;