]> git.basschouten.com Git - openhab-addons.git/blob
422227d002b279da7c1850e42a916c3a82a3144d
[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.wlanthermo.internal;
14
15 import java.net.URI;
16 import java.net.URISyntaxException;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 /**
21  * The {@link WlanThermoConfiguration} class contains fields mapping thing configuration parameters.
22  *
23  * @author Christian Schlipp - Initial contribution
24  */
25 @NonNullByDefault
26 public class WlanThermoConfiguration {
27
28     /**
29      * IP Address of WlanThermo.
30      */
31     private String ipAddress = "";
32
33     /**
34      * Polling interval
35      */
36     private int pollingInterval = 10;
37
38     public String getIpAddress() {
39         return ipAddress;
40     }
41
42     public URI getUri(String path) throws URISyntaxException {
43         String uri = ipAddress;
44         if (!uri.startsWith("http://")) {
45             uri = "http://" + uri;
46         }
47
48         if (!path.startsWith("/") && !uri.endsWith("/")) {
49             uri = uri + "/";
50         }
51         uri = uri + path;
52
53         return new URI(uri);
54     }
55
56     public URI getUri() throws URISyntaxException {
57         return getUri("");
58     }
59
60     public void setIpAddress(String ipAddress) {
61         this.ipAddress = ipAddress;
62     }
63
64     public int getPollingInterval() {
65         return pollingInterval;
66     }
67
68     public void setPollingInterval(int pollingInterval) {
69         this.pollingInterval = pollingInterval;
70     }
71 }