Interface LiveMapPathObject
- All Superinterfaces:
PathObject
PathObject whose underlying value is expected to be a LiveMap.
Provides type-safe access to map-specific operations such as get(String),
entries(), set(String, LiveMapValue), etc.
Calling channel.objects.getRoot()-equivalent navigation methods at the
root of the graph always returns a LiveMapPathObject.
Operations on this type are best-effort: they resolve the path against the local
LiveObjects graph at call time. Read operations return empty/null when the path does
not resolve to a LiveMap; write operations complete the returned
CompletableFuture exceptionally with an AblyException
(status 400, code 92007) in that case.
Spec: RTTS6a
-
Method Summary
Modifier and TypeMethodDescription@NotNull PathObjectReturns a newPathObjectwhose path is this path with the segments parsed frompathappended.@NotNull @Unmodifiable Iterable<Map.Entry<String,PathObject>> entries()Returns the entries (key, childPathObject) of theLiveMapat this path.@NotNull PathObjectkeys()Returns the keys of theLiveMapat this path.@NotNull CompletableFuture<Void>Removes a key from theLiveMapat this path.@NotNull CompletableFuture<Void>set(@NotNull String key, @NotNull LiveMapValue value) Sets a key on theLiveMapat this path to the provided value.@Nullable Longsize()Returns the size of theLiveMapat this path, ornullwhen the path does not resolve to aLiveMap.@NotNull @Unmodifiable Iterable<PathObject>values()Returns the childPathObjects for each key in theLiveMapat this path.Methods inherited from interface io.ably.lib.liveobjects.path.PathObject
asBinary, asBoolean, asJsonArray, asJsonObject, asLiveCounter, asLiveMap, asNumber, asString, compactJson, exists, getType, instance, path, subscribe, subscribe
-
Method Details
-
get
Returns a newPathObjectrepresenting the child atkeyof theLiveMapat this path. Purely navigational - no resolution occurs.Spec: RTPO5
- Parameters:
-
key- the child key to navigate to - Returns:
- a
PathObjectpointing tothis.path + key
-
at
Returns a newPathObjectwhose path is this path with the segments parsed frompathappended. Thepathargument is a dot-delimited string; a backslash-escaped dot (\.) is treated as a literal dot within a segment.This is purely navigational - no resolution against the LiveObjects graph is performed by this call.
liveMapPath.at("a.b.c")is equivalent toliveMapPath.get("a").asLiveMap().get("b").asLiveMap().get("c").Available only on
LiveMapPathObjectbecause deeper navigation is only meaningful when the current resolved value is aLiveMap. To traverse from an arbitraryPathObject, first cast viaPathObject.asLiveMap().Spec: RTPO6
- Parameters:
-
path- dot-delimited path to append to this path - Returns:
- a new
PathObjectrepresenting the deeper path
-
entries
Returns the entries (key, childPathObject) of theLiveMapat this path. Each child path is produced as if by callingget(String)with the corresponding key.Returns an empty iterable when the path does not resolve to a
LiveMap.Spec: RTPO9
- Returns:
- an unmodifiable iterable of map entries; empty when not a LiveMap
-
keys
Returns the keys of theLiveMapat this path.Returns an empty iterable when the path does not resolve to a
LiveMap.Spec: RTPO10
- Returns:
- an unmodifiable iterable of keys; empty when not a LiveMap
-
values
Returns the childPathObjects for each key in theLiveMapat this path.Returns an empty iterable when the path does not resolve to a
LiveMap.Spec: RTPO11
- Returns:
- an unmodifiable iterable of child paths; empty when not a LiveMap
-
size
Returns the size of theLiveMapat this path, ornullwhen the path does not resolve to aLiveMap.Spec: RTPO12
- Returns:
- the number of (non-tombstoned) entries, or
null
-
set
@NotNull @NotNull CompletableFuture<Void> set(@NotNull @NotNull String key, @NotNull @NotNull LiveMapValue value) Sets a key on theLiveMapat this path to the provided value.Sends a
MAP_SEToperation to the realtime system; the local state is updated when the operation is echoed back. The returned future completes exceptionally with anAblyException(status 400, code 92005) if the path cannot be resolved, or (status 400, code 92007) if the resolved value is not aLiveMap.Spec: RTPO15
- Parameters:
-
key- the key to set -
value- the value to associate withkey - Returns:
- a future that completes when the operation has been acknowledged
-
remove
Removes a key from theLiveMapat this path.Sends a
MAP_REMOVEoperation to the realtime system; the local state is updated when the operation is echoed back. Same error conditions asset(String, LiveMapValue)apply.Spec: RTPO16
- Parameters:
-
key- the key to remove - Returns:
- a future that completes when the operation has been acknowledged
-