diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-30 16:58:34 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-30 16:58:34 -0700 |
commit | 9a68d1045f30bf8397d6cbf90df8f42f40979591 (patch) | |
tree | ddaea6ff681f482a4e062127f969fe0cbe40f244 /src/main/java/org/traccar/session | |
parent | 2e83b23d258e74df6dfc1c860c2abf9b1b816181 (diff) | |
download | trackermap-server-9a68d1045f30bf8397d6cbf90df8f42f40979591.tar.gz trackermap-server-9a68d1045f30bf8397d6cbf90df8f42f40979591.tar.bz2 trackermap-server-9a68d1045f30bf8397d6cbf90df8f42f40979591.zip |
Add generic variable store
Diffstat (limited to 'src/main/java/org/traccar/session')
-rw-r--r-- | src/main/java/org/traccar/session/DeviceSession.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/session/DeviceSession.java b/src/main/java/org/traccar/session/DeviceSession.java index 6fe5b5d57..0d5b283fe 100644 --- a/src/main/java/org/traccar/session/DeviceSession.java +++ b/src/main/java/org/traccar/session/DeviceSession.java @@ -15,7 +15,8 @@ */ package org.traccar.session; -import java.util.TimeZone; +import java.util.HashMap; +import java.util.Map; public class DeviceSession { @@ -29,14 +30,25 @@ public class DeviceSession { return deviceId; } - private TimeZone timeZone; + public static final String KEY_TIMEZONE = "timezone"; - public void setTimeZone(TimeZone timeZone) { - this.timeZone = timeZone; + private final Map<String, Object> locals = new HashMap<>(); + + public boolean contains(String key) { + return locals.containsKey(key); + } + + public void set(String key, Object value) { + if (value != null) { + locals.put(key, value); + } else { + locals.remove(key); + } } - public TimeZone getTimeZone() { - return timeZone; + @SuppressWarnings("unchecked") + public <T> T get(String key) { + return (T) locals.get(key); } } |