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.openhab.core.config.core.Configuration;
18 import org.openhab.core.library.types.PointType;
21 * The {@link ConfigHelper} class is a configuration helper for channels and profiles.
23 * @author Gabor Bicskei - Initial contribution
25 public class ConfigHelper {
26 // configuration constants
27 public static final String CONFIG_TRACKER_ID = "trackerId";
28 public static final String CONFIG_REGION_NAME = "regionName";
29 public static final String CONFIG_REGION_RADIUS = "regionRadius";
30 public static final String CONFIG_REGION_CENTER_LOCATION = "regionCenterLocation";
31 public static final String CONFIG_ACCURACY_THRESHOLD = "accuracyThreshold";
36 private ConfigHelper() {
39 public static double getRegionRadius(Configuration config) {
40 return ((BigDecimal) config.get(CONFIG_REGION_RADIUS)).doubleValue();
43 public static double getAccuracyThreshold(Configuration config) {
44 Object value = config.get(CONFIG_ACCURACY_THRESHOLD);
45 return value != null ? ((BigDecimal) value).doubleValue() : 0;
48 public static String getRegionName(Configuration config) {
49 return (String) config.get(CONFIG_REGION_NAME);
52 public static String getTrackerId(Configuration config) {
53 return (String) config.get(CONFIG_TRACKER_ID);
56 public static PointType getRegionCenterLocation(Configuration config) {
57 String location = (String) config.get(CONFIG_REGION_CENTER_LOCATION);
58 return location != null ? new PointType(location) : null;