# Class Session

java.lang.Object
com.google.adk.JsonBaseModel
com.google.adk.sessions.Session

public final class Session extends JsonBaseModel
A `Session` object that encapsulates the `State` and `Event`s of a session.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `Session.Builder`
  Builder for `Session`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `appName()`
  `static Session.Builder`
  `builder(SessionKey sessionKey)`
  Creates a new `Session.Builder` with the given session key.
  `static Session.Builder`
  `builder(String id)`
  `List<Event>`
  `events()`
  `static Session`
  `fromJson(String json)`
  `double`
  `getLastUpdateTimeAsDouble()`
  `String`
  `id()`
  `Instant`
  `lastUpdateTime()`
  `void`
  `lastUpdateTime(Instant lastUpdateTime)`
  `SessionKey`
  `sessionKey()`
  Returns the session key.
  `Map<String,Object>`
  `state()`
  `String`
  `toString()`
  `String`
  `userId()`

  ### Methods inherited from class JsonBaseModel

  `fromJsonNode, fromJsonString, getMapper, toJson, toJsonNode, toJsonString`
  Modifier and Type
  Method
  Description
  `static <T extends JsonBaseModel>
  T`
  `fromJsonNode(com.fasterxml.jackson.databind.JsonNode jsonNode, Class<T> clazz)`
  Deserializes a JsonNode to an object of the given type.
  `static <T extends JsonBaseModel>
  T`
  `fromJsonString(String jsonString, Class<T> clazz)`
  Deserializes a Json string to an object of the given type.
  `static com.fasterxml.jackson.databind.ObjectMapper`
  `getMapper()`
  Returns the mutable ObjectMapper instance used by ADK.
  `String`
  `toJson()`
  Serializes this object (i.e., the ObjectMappper instance used by ADK) to a Json string.
  `protected static com.fasterxml.jackson.databind.JsonNode`
  `toJsonNode(Object object)`
  Serializes an object to a JsonNode.
  `static String`
  `toJsonString(Object object)`
  Serializes an object to a Json string.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### builder

    public static Session.Builder builder(String id)

  - ### builder

    public static Session.Builder builder(SessionKey sessionKey)
    Creates a new `Session.Builder` with the given session key.

  - ### sessionKey

    public SessionKey sessionKey()
    Returns the session key.

  - ### id

    public String id()

  - ### state

    public Map<String,Object> state()

  - ### events

    public List<Event> events()

  - ### appName

    public String appName()

  - ### userId

    public String userId()

  - ### lastUpdateTime

    public void lastUpdateTime(Instant lastUpdateTime)

  - ### lastUpdateTime

    public Instant lastUpdateTime()

  - ### getLastUpdateTimeAsDouble

    public double getLastUpdateTimeAsDouble()

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### fromJson

    public static Session fromJson(String json)