Interface LiveMapInstance

All Superinterfaces:
Instance

public interface LiveMapInstance extends Instance
A Instance bound to a LiveMap. Provides type-safe access to map-specific operations such as get(String), entries() and set(String, LiveMapValue).

Operations are bound to the specific underlying LiveMap, dereferenced in O(1), and do not perform any path resolution.

Spec: RTTS10a

  • Method Details

    • getId

      @NotNull @NotNull String getId()
      Returns the object id of the wrapped LiveMap.

      Spec: RTINS3a

      Returns:
      the wrapped LiveMap's object id
    • compactJson

      @NotNull @NotNull com.google.gson.JsonObject compactJson()
      Returns the compacted JSON snapshot of the wrapped value, narrowed to a JsonObject: a LiveMapInstance compacts to a JSON object (or, for a cyclic reference, an object-id reference object).

      Spec: RTTS7a

      Specified by:
      compactJson in interface Instance
      Returns:
      the compacted JSON object
    • get

      @Nullable @Nullable Instance get(@NotNull @NotNull String key)
      Returns a Instance wrapping the value at key of the wrapped LiveMap, or null when the key is absent / tombstoned.

      Spec: RTINS5

      Parameters:
      key - the key to look up
      Returns:
      an instance wrapping the value at key, or null
    • entries

      @NotNull @NotNull @Unmodifiable Iterable<Map.Entry<String,Instance>> entries()
      Returns the entries (key, child Instance) of the wrapped LiveMap.

      Spec: RTINS6

      Returns:
      an unmodifiable iterable of entries
    • keys

      @NotNull @NotNull @Unmodifiable Iterable<String> keys()
      Returns the keys of the wrapped LiveMap.

      Spec: RTINS7

      Returns:
      an unmodifiable iterable of keys
    • values

      @NotNull @NotNull @Unmodifiable Iterable<Instance> values()
      Returns the child Instances for each value in the wrapped LiveMap.

      Spec: RTINS8

      Returns:
      an unmodifiable iterable of value instances
    • size

      @NotNull @NotNull Long size()
      Returns the number of (non-tombstoned) entries in the wrapped LiveMap.

      Spec: RTINS9

      Returns:
      the map size
    • set

      @NotNull @NotNull CompletableFuture<Void> set(@NotNull @NotNull String key, @NotNull @NotNull LiveMapValue value)
      Sets a key on the wrapped LiveMap to the provided value. Sends a MAP_SET operation to the realtime system; the local state is updated when the operation is echoed back.

      Spec: RTINS12

      Parameters:
      key - the key to set
      value - the value to associate with key
      Returns:
      a future that completes when the operation has been acknowledged
    • remove

      @NotNull @NotNull CompletableFuture<Void> remove(@NotNull @NotNull String key)
      Removes a key from the wrapped LiveMap. Sends a MAP_REMOVE operation to the realtime system; the local state is updated when the operation is echoed back.

      Spec: RTINS13

      Parameters:
      key - the key to remove
      Returns:
      a future that completes when the operation has been acknowledged
    • subscribe

      @NonBlocking @NotNull @NotNull Subscription subscribe(@NotNull @NotNull InstanceListener listener)
      Subscribes a listener for updates on the wrapped LiveMap. The listener is invoked whenever the wrapped map is changed by a local or remote operation. Call Subscription.unsubscribe() on the returned handle to stop receiving events for this listener.

      The subscription is identity-based: it follows the specific underlying LiveMap, regardless of where it sits in the LiveObjects graph.

      Spec: RTTS10a / RTINS16

      Parameters:
      listener - the listener to invoke on updates
      Returns:
      a subscription handle that can be used to unsubscribe this listener