]> git.basschouten.com Git - openhab-addons.git/blob
378b5b6d47230c800a0a60e74f0ec12a5b2d0b4e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.wlanthermo.internal;
14
15 import java.net.URI;
16 import java.net.URISyntaxException;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * The {@link WlanThermoNanoConfiguration} class contains fields mapping thing configuration parameters.
23  *
24  * @author Christian Schlipp - Initial contribution
25  */
26 @NonNullByDefault
27 public class WlanThermoNanoConfiguration {
28
29     /**
30      * IP Address of WlanThermo.
31      */
32     private String ipAddress = "";
33
34     /**
35      * Username of WlanThermo user.
36      */
37     private @Nullable String username;
38
39     /**
40      * Password of WlanThermo user.
41      */
42
43     private @Nullable String password;
44
45     /**
46      * Polling interval
47      */
48     private int pollingInterval = 10;
49
50     public String getIpAddress() {
51         return ipAddress;
52     }
53
54     public URI getUri(String path) throws URISyntaxException {
55         String uri = ipAddress;
56         if (!uri.startsWith("http://")) {
57             uri = "http://" + uri;
58         }
59
60         if (!path.startsWith("/") && !uri.endsWith("/")) {
61             uri = uri + "/";
62         }
63         uri = uri + path;
64
65         return new URI(uri);
66     }
67
68     public URI getUri() throws URISyntaxException {
69         return getUri("");
70     }
71
72     public void setIpAddress(String ipAddress) {
73         this.ipAddress = ipAddress;
74     }
75
76     @Nullable
77     public String getUsername() {
78         return username;
79     }
80
81     public void setUsername(String username) {
82         this.username = username;
83     }
84
85     @Nullable
86     public String getPassword() {
87         return password;
88     }
89
90     public void setPassword(String password) {
91         this.password = password;
92     }
93
94     public int getPollingInterval() {
95         return pollingInterval;
96     }
97
98     public void setPollingInterval(int pollingInterval) {
99         this.pollingInterval = pollingInterval;
100     }
101 }