T
- the typepublic interface SessionKey<T>
A key is a combination of type and name. A key must have a type, or name, or both.
A key stored in the session always has a type parameter.
That is, all keys returned by SessionData.getKeys()
are guaranteed to have a type parameter.
A key with a name only can be used to retrieve an item from the session where the type is not known ahead of time.
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName()
The name.
|
java.lang.Class<T> |
getType()
The type.
|
static <T> SessionKey<T> |
of(java.lang.Class<T> type)
Creates a key of the given type with no name.
|
static SessionKey<?> |
of(java.lang.String name)
Creates a key of the given name with no type.
|
static <T> SessionKey<T> |
of(java.lang.String name,
java.lang.Class<T> type)
Creates a key of the given name and type.
|
static <T> SessionKey<T> |
ofType(java.lang.String name,
T value)
Creates a key of the given name, and the type of the given object (as provided by
Object.getClass() ). |
static <T> SessionKey<T> |
ofType(T value)
Creates a key of type of the given object (as provided by
Object.getClass() ), and no name. |
@Nullable java.lang.String getName()
static <T> SessionKey<T> of(java.lang.Class<T> type)
T
- the typetype
- the typestatic <T> SessionKey<T> of(@Nullable java.lang.String name, @Nullable java.lang.Class<T> type)
If both arguments are null
, an IllegalArgumentException
will be thrown.
T
- the typename
- the nametype
- the typestatic SessionKey<?> of(java.lang.String name)
name
- the namestatic <T> SessionKey<T> ofType(java.lang.String name, T value)
Object.getClass()
).T
- the typename
- the namevalue
- the object who's runtime type will be used as the type of the keystatic <T> SessionKey<T> ofType(T value)
Object.getClass()
), and no name.T
- the typevalue
- the object who's runtime type will be used as the type of the key