Class State
java.lang.Object
com.google.adk.sessions.State
Session state that also records each write made through
put(String, Object), remove(Object) and the other write methods in a delta. Writes through the entrySet(),
keySet() and values() views and clear() skip the delta, so no event
carries them; in the Context.state() of a workflow node, and in a
tool context under a state schema, they throw UnsupportedOperationException.-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the backing map without recording removals in the delta.@Nullable Objectcompute(String key, BiFunction<? super String, ? super @Nullable Object, ? extends @Nullable Object> remappingFunction) @Nullable ObjectcomputeIfAbsent(String key, Function<? super String, ? extends @Nullable Object> mappingFunction) @Nullable ObjectcomputeIfPresent(String key, BiFunction<? super String, ? super Object, ? extends @Nullable Object> remappingFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) static StatedelegatingCompute(ConcurrentMap<String, Object> state, ConcurrentMap<String, Object> delta) Returns a state whosecompute*andmergemethods callstate's own, so they return whatstatestores.entrySet()Returns the entries view; read-only in a workflow node or a tool context under a state schema, and writes elsewhere skip the delta.booleanbooleanhasDelta()inthashCode()booleanisEmpty()keySet()Returns the key set view; read-only in a workflow node or a tool context under a state schema, and writes elsewhere skip the delta.@Nullable Objectmerge(String key, Object value, BiFunction<? super Object, ? super Object, ? extends @Nullable Object> remappingFunction) voidputIfAbsent(String key, Object value) booleanbooleanintsize()values()Returns the values view; read-only in a workflow node or a tool context under a state schema, and writes elsewhere skip the delta.Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ConcurrentMap
forEach, getOrDefault, replaceAll
-
Field Details
-
APP_PREFIX
- See Also:
-
USER_PREFIX
- See Also:
-
TEMP_PREFIX
- See Also:
-
REMOVED
Sentinel object to mark removed entries in the delta map.
-
-
Constructor Details
-
State
-
State
-
-
Method Details
-
delegatingCompute
@Experimental public static State delegatingCompute(ConcurrentMap<String, Object> state, ConcurrentMap<String, Object> delta) Returns a state whosecompute*andmergemethods callstate's own, so they return whatstatestores.statemust record those writes indeltaitself, which this state shares; the other write methods behave as inState(Map, Map). -
clear
public void clear()Clears the backing map without recording removals in the delta.- Specified by:
clearin interfaceMap<String,Object> - Throws:
UnsupportedOperationException- if this state belongs to a workflow node's context, or to a tool context under a state schema
-
containsKey
- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,Object>
-
entrySet
-
equals
-
get
-
hashCode
-
isEmpty
-
keySet
-
put
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<String,Object> - Specified by:
putIfAbsentin interfaceMap<String,Object>
-
putAll
-
remove
-
remove
-
replace
-
replace
-
compute
-
computeIfAbsent
@CanIgnoreReturnValue public @Nullable Object computeIfAbsent(String key, Function<? super String, ? extends @Nullable Object> mappingFunction) - Specified by:
computeIfAbsentin interfaceConcurrentMap<String,Object> - Specified by:
computeIfAbsentin interfaceMap<String,Object>
-
computeIfPresent
@CanIgnoreReturnValue public @Nullable Object computeIfPresent(String key, BiFunction<? super String, ? super Object, ? extends @Nullable Object> remappingFunction) - Specified by:
computeIfPresentin interfaceConcurrentMap<String,Object> - Specified by:
computeIfPresentin interfaceMap<String,Object>
-
merge
-
size
-
values
-
hasDelta
public boolean hasDelta()
-