]> git.basschouten.com Git - openhab-addons.git/blob
08601d054aa8d6696b37f13a27b95ca64082ed97
[openhab-addons.git] /
1 /**
2  * Copyright 2017-2018 Gregory Moyer and contributors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.openhab.binding.lametrictime.api;
17
18 import org.openhab.binding.lametrictime.api.cloud.CloudConfiguration;
19 import org.openhab.binding.lametrictime.api.local.LocalConfiguration;
20
21 public class Configuration
22 {
23     private String deviceHost;
24     private String deviceApiKey;
25
26     private boolean ignoreDeviceCertificateValidation = true;
27     private boolean ignoreDeviceHostnameValidation = true;
28
29     private boolean logging = false;
30     private String logLevel = "INFO";
31     private int logMax = 104857600; // 100kb
32
33     public String getDeviceHost()
34     {
35         return deviceHost;
36     }
37
38     public void setDeviceHost(String deviceHost)
39     {
40         this.deviceHost = deviceHost;
41     }
42
43     public Configuration withDeviceHost(String deviceHost)
44     {
45         this.deviceHost = deviceHost;
46         return this;
47     }
48
49     public String getDeviceApiKey()
50     {
51         return deviceApiKey;
52     }
53
54     public void setDeviceApiKey(String deviceApiKey)
55     {
56         this.deviceApiKey = deviceApiKey;
57     }
58
59     public Configuration withDeviceApiKey(String deviceApiKey)
60     {
61         this.deviceApiKey = deviceApiKey;
62         return this;
63     }
64
65     public boolean isIgnoreDeviceCertificateValidation()
66     {
67         return ignoreDeviceCertificateValidation;
68     }
69
70     public void setIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation)
71     {
72         this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation;
73     }
74
75     public Configuration withIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation)
76     {
77         this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation;
78         return this;
79     }
80
81     public boolean isIgnoreDeviceHostnameValidation()
82     {
83         return ignoreDeviceHostnameValidation;
84     }
85
86     public void setIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation)
87     {
88         this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation;
89     }
90
91     public Configuration withIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation)
92     {
93         this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation;
94         return this;
95     }
96
97     public boolean isLogging()
98     {
99         return logging;
100     }
101
102     public void setLogging(boolean logging)
103     {
104         this.logging = logging;
105     }
106
107     public Configuration withLogging(boolean logging)
108     {
109         this.logging = logging;
110         return this;
111     }
112
113     public String getLogLevel()
114     {
115         return logLevel;
116     }
117
118     public void setLogLevel(String logLevel)
119     {
120         this.logLevel = logLevel;
121     }
122
123     public Configuration withLogLevel(String logLevel)
124     {
125         this.logLevel = logLevel;
126         return this;
127     }
128
129     public int getLogMax()
130     {
131         return logMax;
132     }
133
134     public void setLogMax(int logMax)
135     {
136         this.logMax = logMax;
137     }
138
139     public Configuration withLogMax(int logMax)
140     {
141         this.logMax = logMax;
142         return this;
143     }
144
145     public LocalConfiguration getLocalConfig()
146     {
147         return new LocalConfiguration().withHost(deviceHost)
148                                        .withApiKey(deviceApiKey)
149                                        .withIgnoreCertificateValidation(ignoreDeviceCertificateValidation)
150                                        .withIgnoreHostnameValidation(ignoreDeviceHostnameValidation)
151                                        .withLogging(logging)
152                                        .withLogLevel(logLevel)
153                                        .withLogMax(logMax);
154     }
155
156     public CloudConfiguration getCloudConfig()
157     {
158         return new CloudConfiguration().withLogging(logging)
159                                        .withLogLevel(logLevel)
160                                        .withLogMax(logMax);
161     }
162 }