-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
Description
Session is implemented as a Map<Object, Object>, so we have a single way to access session values: session.get(key), which returns an Object.
Most of the time we know what we are storing in the session though, and we have to cast the result of get:
String myString = (String) context.getSession().get("myKey");While this is fine for simple types it is annoying for complex ones, especially when accessed in transitions where we typically want a compact syntax:
myState.body(...)
.next()
.when(((MyComplexType)context.getSession().get("myKey")).getX() == 2).moveTo(...)This could be simplified by implementing typed getters for the session:
myState.body(...)
.next()
.when(context.getSession().get("myKey", MyComplexType.class).getX() == 2).moveTo(...)Additional getters could be provided for basic types: getAsString, getAsInt, etc