Interface LiveCounterPathObject

All Superinterfaces:
PathObject

public interface LiveCounterPathObject extends PathObject
A PathObject whose underlying value is expected to be a LiveCounter. Provides type-safe access to counter operations such as value(), increment(Number) and decrement(Number).

Counters are terminal nodes - navigation via at(...) is not available here because it is only defined on LiveMapPathObject.

Operations are best-effort and resolve the path at call time. Read operations return null when the path does not resolve to a LiveCounter; write operations complete the returned CompletableFuture exceptionally with an AblyException (status 400, code 92007) in that case.

Spec: RTTS6b

  • Method Details

    • value

      @Nullable @Nullable Double value()
      Returns the current value of the LiveCounter at this path, or null when the path does not resolve to a LiveCounter.

      Spec: RTPO7 / RTLC5

      Returns:
      the counter value, or null
    • increment

      @NotNull @NotNull CompletableFuture<Void> increment()
      Increments the LiveCounter at this path by 1. Equivalent to calling increment(Number) with 1.

      Spec: RTPO17a1 (default amount of 1)

      Returns:
      a future that completes when the operation has been acknowledged
    • increment

      @NotNull @NotNull CompletableFuture<Void> increment(@NotNull @NotNull Number amount)
      Increments the LiveCounter at this path by amount.

      Sends a COUNTER_INC operation to the realtime system; the local state is updated when the operation is echoed back. The returned future completes exceptionally with an AblyException (status 400, code 92005) if the path cannot be resolved, or (status 400, code 92007) if the resolved value is not a LiveCounter.

      Spec: RTPO17

      Parameters:
      amount - the amount to add (may be negative)
      Returns:
      a future that completes when the operation has been acknowledged
    • decrement

      @NotNull @NotNull CompletableFuture<Void> decrement()
      Decrements the LiveCounter at this path by 1. Equivalent to calling decrement(Number) with 1.

      Spec: RTPO18a1 (default amount of 1)

      Returns:
      a future that completes when the operation has been acknowledged
    • decrement

      @NotNull @NotNull CompletableFuture<Void> decrement(@NotNull @NotNull Number amount)
      Decrements the LiveCounter at this path by amount. Equivalent to calling increment(Number) with a negated value.

      Spec: RTPO18

      Parameters:
      amount - the amount to subtract (may be negative)
      Returns:
      a future that completes when the operation has been acknowledged