make shared state easier to use

This commit is contained in:
Jonathan Shook
2022-05-25 11:59:36 -05:00
parent 795050fbd6
commit c1143e4fa2

View File

@@ -39,4 +39,18 @@ public class SharedState {
public static ConcurrentHashMap<String,Object> gl_ObjectMap = public static ConcurrentHashMap<String,Object> gl_ObjectMap =
new ConcurrentHashMap<>(); new ConcurrentHashMap<>();
public static <T> T put(Scope scope, String name, T value) {
return switch(scope) {
case process -> (T) gl_ObjectMap.put(name, value);
case thread -> (T) tl_ObjectMap.get().put(name, value);
};
}
public static <T> T get(Scope scope, String name) {
return switch(scope) {
case process -> (T) gl_ObjectMap.get(name);
case thread -> (T) tl_ObjectMap.get().get(name);
};
}
} }