aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/config/Config.java
diff options
context:
space:
mode:
authorAnton Tananaev <atananaev@lyft.com>2020-12-28 14:34:05 -0800
committerAnton Tananaev <atananaev@lyft.com>2020-12-28 14:34:05 -0800
commit45a98c81bc5c9510dfe25f91b0e84d7608eaf7eb (patch)
tree21ae76e3f914eff0850862cf258f43a8473852d3 /src/main/java/org/traccar/config/Config.java
parentea0e6285be71112c5049d4712a2a31c8348dc9cc (diff)
downloadtrackermap-server-45a98c81bc5c9510dfe25f91b0e84d7608eaf7eb.tar.gz
trackermap-server-45a98c81bc5c9510dfe25f91b0e84d7608eaf7eb.tar.bz2
trackermap-server-45a98c81bc5c9510dfe25f91b0e84d7608eaf7eb.zip
Refactor double keys
Diffstat (limited to 'src/main/java/org/traccar/config/Config.java')
-rw-r--r--src/main/java/org/traccar/config/Config.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/config/Config.java b/src/main/java/org/traccar/config/Config.java
index 1231918c6..c6d87bfd6 100644
--- a/src/main/java/org/traccar/config/Config.java
+++ b/src/main/java/org/traccar/config/Config.java
@@ -134,16 +134,22 @@ public class Config {
return hasKey(key) ? Long.parseLong(getString(key)) : defaultValue;
}
- public double getDouble(ConfigKey key) {
- return getDouble(key, 0.0);
- }
-
- public double getDouble(ConfigKey key, double defaultValue) {
- return hasKey(key.getKey()) ? Double.parseDouble(getString(key.getKey())) : defaultValue;
+ public double getDouble(ConfigKey<Double> key) {
+ String value = getString(key.getKey());
+ if (value != null) {
+ return Double.parseDouble(value);
+ } else {
+ Double defaultValue = key.getDefaultValue();
+ if (defaultValue != null) {
+ return defaultValue;
+ } else {
+ return 0;
+ }
+ }
}
@VisibleForTesting
- public void setString(ConfigKey key, String value) {
+ public void setString(ConfigKey<?> key, String value) {
properties.put(key.getKey(), value);
}