blob: 09c055a28d481a18d86111254b4621eb5a195f7b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package tools.refinery.language.web.xtext.servlet;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.xtext.web.server.ISession;
import org.eclipse.xtext.xbase.lib.Functions.Function0;
public class SimpleSession implements ISession {
private Map<Object, Object> map = new HashMap<>();
@Override
public <T> T get(Object key) {
@SuppressWarnings("unchecked")
var value = (T) map.get(key);
return value;
}
@Override
public <T> T get(Object key, Function0<? extends T> factory) {
@SuppressWarnings("unchecked")
var value = (T) map.computeIfAbsent(key, absentKey -> factory.apply());
return value;
}
@Override
public void put(Object key, Object value) {
map.put(key, value);
}
@Override
public void remove(Object key) {
map.remove(key);
}
}
|