]> git.basschouten.com Git - openhab-addons.git/blob
de08de57e29a9549cbafd61370ae170bf8d6840f
[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.airquality.internal.config;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.airquality.internal.AirQualityException;
17
18 /**
19  * The {@link AirQualityConfiguration} is the class used to match the
20  * thing configuration.
21  *
22  * @author Kuba Wolanin - Initial contribution
23  */
24 @NonNullByDefault
25 public class AirQualityConfiguration {
26     public static final String LOCATION = "location";
27     public static final String STATION_ID = "stationId";
28
29     public String location = "";
30     public int stationId = 0;
31     public int refresh = 60;
32
33     public void checkValid() throws AirQualityException {
34         if (location.trim().isEmpty() && stationId == 0) {
35             throw new AirQualityException("Either 'location' or 'stationId' is mandatory and must be configured");
36         }
37         if (refresh < 30) {
38             throw new AirQualityException("Parameter 'refresh' must be at least 30 minutes");
39         }
40     }
41 }