]> git.basschouten.com Git - openhab-addons.git/blob
8d1e4f94f02fbc5eb1bf9222c6e25ea549b4cf20
[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.lametrictime.internal.api;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.lametrictime.internal.api.cloud.CloudConfiguration;
18 import org.openhab.binding.lametrictime.internal.api.local.LocalConfiguration;
19
20 /**
21  * Configuration class for LaMetric Time.
22  *
23  * @author Gregory Moyer - Initial contribution
24  */
25 @NonNullByDefault
26 public class Configuration {
27     @Nullable
28     private String deviceHost;
29     @Nullable
30     private String deviceApiKey;
31
32     private boolean ignoreDeviceCertificateValidation = true;
33     private boolean ignoreDeviceHostnameValidation = true;
34
35     private boolean logging = false;
36     private String logLevel = "INFO";
37     private int logMax = 104857600; // 100kb
38
39     public @Nullable String getDeviceHost() {
40         return deviceHost;
41     }
42
43     public void setDeviceHost(String deviceHost) {
44         this.deviceHost = deviceHost;
45     }
46
47     public Configuration withDeviceHost(@Nullable String deviceHost) {
48         this.deviceHost = deviceHost;
49         return this;
50     }
51
52     public @Nullable String getDeviceApiKey() {
53         return deviceApiKey;
54     }
55
56     public void setDeviceApiKey(String deviceApiKey) {
57         this.deviceApiKey = deviceApiKey;
58     }
59
60     public Configuration withDeviceApiKey(@Nullable String deviceApiKey) {
61         this.deviceApiKey = deviceApiKey;
62         return this;
63     }
64
65     public boolean isIgnoreDeviceCertificateValidation() {
66         return ignoreDeviceCertificateValidation;
67     }
68
69     public void setIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation) {
70         this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation;
71     }
72
73     public Configuration withIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation) {
74         this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation;
75         return this;
76     }
77
78     public boolean isIgnoreDeviceHostnameValidation() {
79         return ignoreDeviceHostnameValidation;
80     }
81
82     public void setIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation) {
83         this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation;
84     }
85
86     public Configuration withIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation) {
87         this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation;
88         return this;
89     }
90
91     public boolean isLogging() {
92         return logging;
93     }
94
95     public void setLogging(boolean logging) {
96         this.logging = logging;
97     }
98
99     public Configuration withLogging(boolean logging) {
100         this.logging = logging;
101         return this;
102     }
103
104     public String getLogLevel() {
105         return logLevel;
106     }
107
108     public void setLogLevel(String logLevel) {
109         this.logLevel = logLevel;
110     }
111
112     public Configuration withLogLevel(String logLevel) {
113         this.logLevel = logLevel;
114         return this;
115     }
116
117     public int getLogMax() {
118         return logMax;
119     }
120
121     public void setLogMax(int logMax) {
122         this.logMax = logMax;
123     }
124
125     public Configuration withLogMax(int logMax) {
126         this.logMax = logMax;
127         return this;
128     }
129
130     public LocalConfiguration getLocalConfig() {
131         return new LocalConfiguration().withHost(deviceHost).withApiKey(deviceApiKey)
132                 .withIgnoreCertificateValidation(ignoreDeviceCertificateValidation)
133                 .withIgnoreHostnameValidation(ignoreDeviceHostnameValidation).withLogging(logging)
134                 .withLogLevel(logLevel).withLogMax(logMax);
135     }
136
137     public CloudConfiguration getCloudConfig() {
138         return new CloudConfiguration().withLogging(logging).withLogLevel(logLevel).withLogMax(logMax);
139     }
140 }