diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-14 18:42:28 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-14 18:42:28 -0700 |
commit | 204e98895b3cd9a37ceea1760917c07606b36b10 (patch) | |
tree | b73a44da2aa98d0dab3870efb59be09ae5ffaaf1 /src/main/java/org/traccar/notification | |
parent | 900601111466aa861db8ae77b71b95aec6c8c82e (diff) | |
download | trackermap-server-204e98895b3cd9a37ceea1760917c07606b36b10.tar.gz trackermap-server-204e98895b3cd9a37ceea1760917c07606b36b10.tar.bz2 trackermap-server-204e98895b3cd9a37ceea1760917c07606b36b10.zip |
Migrate SMTP settings
Diffstat (limited to 'src/main/java/org/traccar/notification')
-rw-r--r-- | src/main/java/org/traccar/notification/PropertiesProvider.java | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/main/java/org/traccar/notification/PropertiesProvider.java b/src/main/java/org/traccar/notification/PropertiesProvider.java index f0078feef..4ffad432c 100644 --- a/src/main/java/org/traccar/notification/PropertiesProvider.java +++ b/src/main/java/org/traccar/notification/PropertiesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.traccar.notification; import org.traccar.config.Config; +import org.traccar.config.ConfigKey; import org.traccar.model.ExtendedModel; public class PropertiesProvider { @@ -32,36 +33,28 @@ public class PropertiesProvider { this.extendedModel = extendedModel; } - public String getString(String key) { + public String getString(ConfigKey<String> key) { if (config != null) { return config.getString(key); } else { - return extendedModel.getString(key); + return extendedModel.getString(key.getKey()); } } - public String getString(String key, String defaultValue) { - String value = getString(key); - if (value == null) { - value = defaultValue; - } - return value; - } - - public int getInteger(String key, int defaultValue) { + public int getInteger(ConfigKey<Integer> key) { if (config != null) { - return config.getInteger(key, defaultValue); + return config.getInteger(key); } else { - Object result = extendedModel.getAttributes().get(key); + Object result = extendedModel.getAttributes().get(key.getKey()); if (result != null) { return result instanceof String ? Integer.parseInt((String) result) : (Integer) result; } else { - return defaultValue; + return key.getDefaultValue(); } } } - public Boolean getBoolean(String key) { + public Boolean getBoolean(ConfigKey<Boolean> key) { if (config != null) { if (config.hasKey(key)) { return config.getBoolean(key); @@ -69,7 +62,7 @@ public class PropertiesProvider { return null; } } else { - Object result = extendedModel.getAttributes().get(key); + Object result = extendedModel.getAttributes().get(key.getKey()); if (result != null) { return result instanceof String ? Boolean.valueOf((String) result) : (Boolean) result; } else { |