Package ratpack.session
Interface SessionKey<T>
-
- Type Parameters:
T
- the type
public interface SessionKey<T>
A key for an object in the session.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.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description String
getName()
The name.Class<T>
getType()
The type.static <T> SessionKey<T>
of(Class<T> type)
Creates a key of the given type with no name.static SessionKey<?>
of(String name)
Creates a key of the given name with no type.static <T> SessionKey<T>
of(String name, Class<T> type)
Creates a key of the given name and type.static <T> SessionKey<T>
ofType(String name, T value)
Creates a key of the given name, and the type of the given object (as provided byObject.getClass()
).static <T> SessionKey<T>
ofType(T value)
Creates a key of type of the given object (as provided byObject.getClass()
), and no name.
-
-
-
Method Detail
-
of
static <T> SessionKey<T> of(Class<T> type)
Creates a key of the given type with no name.- Type Parameters:
T
- the type- Parameters:
type
- the type- Returns:
- a session key
-
of
static <T> SessionKey<T> of(@Nullable String name, @Nullable Class<T> type)
Creates a key of the given name and type.If both arguments are
null
, anIllegalArgumentException
will be thrown.- Type Parameters:
T
- the type- Parameters:
name
- the nametype
- the type- Returns:
- a session key
-
of
static SessionKey<?> of(String name)
Creates a key of the given name with no type.- Parameters:
name
- the name- Returns:
- a session key
-
ofType
static <T> SessionKey<T> ofType(String name, T value)
Creates a key of the given name, and the type of the given object (as provided byObject.getClass()
).- Type Parameters:
T
- the type- Parameters:
name
- the namevalue
- the object who's runtime type will be used as the type of the key- Returns:
- a session key
-
ofType
static <T> SessionKey<T> ofType(T value)
Creates a key of type of the given object (as provided byObject.getClass()
), and no name.- Type Parameters:
T
- the type- Parameters:
value
- the object who's runtime type will be used as the type of the key- Returns:
- a session key
-
-