From 9a68d1045f30bf8397d6cbf90df8f42f40979591 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 30 May 2022 16:58:34 -0700 Subject: Add generic variable store --- .../java/org/traccar/session/DeviceSession.java | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/main/java/org/traccar/session') 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 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 get(String key) { + return (T) locals.get(key); } } -- cgit v1.2.3