Package io.ably.lib.objects.type.map
Interface LiveMap
- All Superinterfaces:
-
LiveMapChange,ObjectLifecycleChange
The LiveMap interface provides methods to interact with a live, real-time map structure.
It supports both synchronous and asynchronous operations for managing key-value pairs.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.ably.lib.objects.type.map.LiveMapChange
LiveMapChange.ListenerNested classes/interfaces inherited from interface io.ably.lib.objects.type.ObjectLifecycleChange
ObjectLifecycleChange.Listener -
Method Summary
Modifier and TypeMethodDescription@NotNull @Unmodifiable Iterable<Map.Entry<String,LiveMapValue>> entries()Retrieves all entries (key-value pairs) in the map.@Nullable LiveMapValueRetrieves the value associated with the specified key.keys()Retrieves all keys in the map.voidRemoves the specified key and its associated value from the map.voidremoveAsync(@NotNull String keyName, @NotNull ObjectsCallback<Void> callback) Asynchronously removes the specified key and its associated value from the map.voidset(@NotNull String keyName, @NotNull LiveMapValue value) Sets the specified key to the given value in the map.voidsetAsync(@NotNull String keyName, @NotNull LiveMapValue value, @NotNull ObjectsCallback<Void> callback) Asynchronously sets the specified key to the given value in the map.@NotNull Longsize()Retrieves the number of entries in the map.@NotNull @Unmodifiable Iterable<LiveMapValue>values()Retrieves all values in the map.Methods inherited from interface io.ably.lib.objects.type.map.LiveMapChange
subscribe, unsubscribe, unsubscribeAllMethods inherited from interface io.ably.lib.objects.type.ObjectLifecycleChange
off, offAll, on
-
Method Details
-
get
Retrieves the value associated with the specified key. If this map object is tombstoned (deleted), null is returned. If no entry is associated with the specified key, null is returned. If map entry is tombstoned (deleted), null is returned. If the value associated with the provided key is an objectId string of another RealtimeObject, a reference to that RealtimeObject is returned, provided it exists in the local pool and is not tombstoned. Otherwise, null is returned. If the value is not an objectId, then that value is returned. Spec: RTLM5, RTLM5a- Parameters:
-
keyName- the key whose associated value is to be returned. - Returns:
- the value associated with the specified key, or null if the key does not exist.
-
entries
Retrieves all entries (key-value pairs) in the map. Spec: RTLM11, RTLM11a- Returns:
- an iterable collection of all entries in the map.
-
keys
Retrieves all keys in the map. Spec: RTLM12, RTLM12a- Returns:
- an iterable collection of all keys in the map.
-
values
Retrieves all values in the map. Spec: RTLM13, RTLM13a- Returns:
- an iterable collection of all values in the map.
-
set
Sets the specified key to the given value in the map. Send a MAP_SET operation to the realtime system to set a key on this LiveMap object to a specified value. This does not modify the underlying data of this LiveMap object. Instead, the change will be applied when the published MAP_SET operation is echoed back to the client and applied to the object following the regular operation application procedure. Spec: RTLM20- Parameters:
-
keyName- the key to be set. -
value- the value to be associated with the key.
-
remove
Removes the specified key and its associated value from the map. Send a MAP_REMOVE operation to the realtime system to tombstone a key on this LiveMap object. This does not modify the underlying data of this LiveMap object. Instead, the change will be applied when the published MAP_REMOVE operation is echoed back to the client and applied to the object following the regular operation application procedure. Spec: RTLM21- Parameters:
-
keyName- the key to be removed.
-
size
Retrieves the number of entries in the map. Spec: RTLM10, RTLM10a- Returns:
- the size of the map.
-
setAsync
@NonBlocking void setAsync(@NotNull @NotNull String keyName, @NotNull @NotNull LiveMapValue value, @NotNull @NotNull ObjectsCallback<Void> callback) Asynchronously sets the specified key to the given value in the map. Send a MAP_SET operation to the realtime system to set a key on this LiveMap object to a specified value. This does not modify the underlying data of this LiveMap object. Instead, the change will be applied when the published MAP_SET operation is echoed back to the client and applied to the object following the regular operation application procedure. Spec: RTLM20- Parameters:
-
keyName- the key to be set. -
value- the value to be associated with the key. -
callback- the callback to handle the result or any errors.
-
removeAsync
@NonBlocking void removeAsync(@NotNull @NotNull String keyName, @NotNull @NotNull ObjectsCallback<Void> callback) Asynchronously removes the specified key and its associated value from the map. Send a MAP_REMOVE operation to the realtime system to tombstone a key on this LiveMap object. This does not modify the underlying data of this LiveMap object. Instead, the change will be applied when the published MAP_REMOVE operation is echoed back to the client and applied to the object following the regular operation application procedure. Spec: RTLM21- Parameters:
-
keyName- the key to be removed. -
callback- the callback to handle the result or any errors.
-