2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.gpstracker.internal.config;
15 import java.math.BigDecimal;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.config.core.Configuration;
20 import org.openhab.core.library.types.PointType;
23 * The {@link ConfigHelper} class is a configuration helper for channels and profiles.
25 * @author Gabor Bicskei - Initial contribution
28 public class ConfigHelper {
29 // configuration constants
30 public static final String CONFIG_TRACKER_ID = "trackerId";
31 public static final String CONFIG_REGION_NAME = "regionName";
32 public static final String CONFIG_REGION_RADIUS = "regionRadius";
33 public static final String CONFIG_REGION_CENTER_LOCATION = "regionCenterLocation";
34 public static final String CONFIG_ACCURACY_THRESHOLD = "accuracyThreshold";
39 private ConfigHelper() {
42 public static double getRegionRadius(Configuration config) {
43 return ((BigDecimal) config.get(CONFIG_REGION_RADIUS)).doubleValue();
46 public static double getAccuracyThreshold(Configuration config) {
47 Object value = config.get(CONFIG_ACCURACY_THRESHOLD);
48 return value != null ? ((BigDecimal) value).doubleValue() : 0;
51 public static String getRegionName(Configuration config) {
52 return (String) config.get(CONFIG_REGION_NAME);
55 public static String getTrackerId(Configuration config) {
56 return (String) config.get(CONFIG_TRACKER_ID);
59 public static @Nullable PointType getRegionCenterLocation(Configuration config) {
60 String location = (String) config.get(CONFIG_REGION_CENTER_LOCATION);
61 return location != null ? new PointType(location) : null;