]> git.basschouten.com Git - openhab-addons.git/blob
2c6f74d5b1762a506b28dcbb3a81381169b390a9
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.salus.internal.handler;
14
15 import static org.openhab.binding.salus.internal.SalusBindingConstants.SalusCloud.DEFAULT_URL;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * @author Martin GrzeĊ›lowski - Initial contribution
21  */
22 @NonNullByDefault
23 public class CloudBridgeConfig {
24     private String username = "";
25     private String password = "";
26     private String url = "";
27     private long refreshInterval = 30;
28     private long propertiesRefreshInterval = 5;
29     private int maxHttpRetries = 3;
30
31     public CloudBridgeConfig() {
32     }
33
34     public CloudBridgeConfig(String username, String password, String url, long refreshInterval,
35             long propertiesRefreshInterval) {
36         this.username = username;
37         this.password = password;
38         this.url = url;
39         this.refreshInterval = refreshInterval;
40         this.propertiesRefreshInterval = propertiesRefreshInterval;
41     }
42
43     public String getUsername() {
44         return username;
45     }
46
47     public void setUsername(String username) {
48         this.username = username;
49     }
50
51     public String getPassword() {
52         return password;
53     }
54
55     public void setPassword(String password) {
56         this.password = password;
57     }
58
59     public String getUrl() {
60         if (url.isBlank()) {
61             return DEFAULT_URL;
62         }
63         return url;
64     }
65
66     public void setUrl(String url) {
67         this.url = url;
68     }
69
70     public long getRefreshInterval() {
71         return refreshInterval;
72     }
73
74     public void setRefreshInterval(long refreshInterval) {
75         this.refreshInterval = refreshInterval;
76     }
77
78     public long getPropertiesRefreshInterval() {
79         return propertiesRefreshInterval;
80     }
81
82     public void setPropertiesRefreshInterval(long propertiesRefreshInterval) {
83         this.propertiesRefreshInterval = propertiesRefreshInterval;
84     }
85
86     public int getMaxHttpRetries() {
87         return maxHttpRetries;
88     }
89
90     public void setMaxHttpRetries(int maxHttpRetries) {
91         this.maxHttpRetries = maxHttpRetries;
92     }
93
94     public boolean isValid() {
95         return !username.isBlank() && !password.isBlank();
96     }
97
98     @Override
99     public String toString() {
100         return "CloudBridgeConfig{" + "username='" + username + '\'' + ", password='<SECRET>'" + ", url='" + url + '\''
101                 + ", refreshInterval=" + refreshInterval + ", propertiesRefreshInterval=" + propertiesRefreshInterval
102                 + '}';
103     }
104 }