Package ai.preferred.venom
Class Session
- java.lang.Object
-
- ai.preferred.venom.Session
-
public final class Session extends Object
- Author:
- Maksim Tkachenko
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Session.Builder
Builder for Session.static class
Session.Key<T>
A class representing the key for a session.
-
Field Summary
Fields Modifier and Type Field Description static Session
EMPTY_SESSION
An instance of an empty session.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Session.Builder
builder()
Create a new instance of builder.<T> T
get(@NotNull Session.Key<T> key)
Returns the session variable from the store.static <T> Session
singleton(@NotNull Session.Key<T> key, T value)
Constructs a singleton session.
-
-
-
Field Detail
-
EMPTY_SESSION
public static final Session EMPTY_SESSION
An instance of an empty session.
-
-
Method Detail
-
singleton
public static <T> Session singleton(@NotNull @NotNull Session.Key<T> key, @Nullable T value)
Constructs a singleton session.- Type Parameters:
T
- the type of the value of the session variable- Parameters:
key
- an unique identifier of the session variablevalue
- the value of the session variable- Returns:
- An instance of session with single key-value pair
-
builder
public static Session.Builder builder()
Create a new instance of builder.- Returns:
- A new instance of builder
-
get
public <T> T get(@NotNull @NotNull Session.Key<T> key)
Returns the session variable from the store.- Type Parameters:
T
- the type of the value of the session variable being retrieved- Parameters:
key
- the name of the session variable to retrieve- Returns:
- the value of the session variable stored
-
-