aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler/TimeHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-03-30 19:36:35 -0700
committerAnton Tananaev <anton@traccar.org>2024-03-30 19:36:35 -0700
commit0f7ec1247cff1a68ffa57ade3f45b11f6602e262 (patch)
tree8cd0006e2b9d2313ef6ff4291188e30d40456701 /src/main/java/org/traccar/handler/TimeHandler.java
parentf84e2710e05660822633ec9e61cde44c03a42d7e (diff)
downloadtrackermap-server-0f7ec1247cff1a68ffa57ade3f45b11f6602e262.tar.gz
trackermap-server-0f7ec1247cff1a68ffa57ade3f45b11f6602e262.tar.bz2
trackermap-server-0f7ec1247cff1a68ffa57ade3f45b11f6602e262.zip
Make handlers nullable
Diffstat (limited to 'src/main/java/org/traccar/handler/TimeHandler.java')
-rw-r--r--src/main/java/org/traccar/handler/TimeHandler.java22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/main/java/org/traccar/handler/TimeHandler.java b/src/main/java/org/traccar/handler/TimeHandler.java
index 2e703c681..052ad41c3 100644
--- a/src/main/java/org/traccar/handler/TimeHandler.java
+++ b/src/main/java/org/traccar/handler/TimeHandler.java
@@ -26,18 +26,12 @@ import java.util.Set;
public class TimeHandler extends BasePositionHandler {
- private final boolean enabled;
private final boolean useServerTime;
private final Set<String> protocols;
@Inject
public TimeHandler(Config config) {
- enabled = config.hasKey(Keys.TIME_OVERRIDE);
- if (enabled) {
- useServerTime = config.getString(Keys.TIME_OVERRIDE).equalsIgnoreCase("serverTime");
- } else {
- useServerTime = false;
- }
+ useServerTime = config.getString(Keys.TIME_OVERRIDE).equalsIgnoreCase("serverTime");
String protocolList = config.getString(Keys.TIME_PROTOCOLS);
if (protocolList != null) {
protocols = new HashSet<>(Arrays.asList(protocolList.split("[, ]")));
@@ -49,14 +43,12 @@ public class TimeHandler extends BasePositionHandler {
@Override
public void handlePosition(Position position, Callback callback) {
- if (enabled) {
- if (protocols == null || protocols.contains(position.getProtocol())) {
- if (useServerTime) {
- position.setDeviceTime(position.getServerTime());
- position.setFixTime(position.getServerTime());
- } else {
- position.setFixTime(position.getDeviceTime());
- }
+ if (protocols == null || protocols.contains(position.getProtocol())) {
+ if (useServerTime) {
+ position.setDeviceTime(position.getServerTime());
+ position.setFixTime(position.getServerTime());
+ } else {
+ position.setFixTime(position.getDeviceTime());
}
}
callback.processed(position);