Class LiveCounter

java.lang.Object
io.ably.lib.liveobjects.value.LiveCounter

public abstract class LiveCounter extends Object
An immutable value type representing the intent to create a new LiveCounter object with a specific initial count. Passed to mutation methods (such as LiveMapInstance#set or LiveMapPathObject#set, wrapped via LiveMapValue.of(LiveCounter)) to assign a new LiveCounter to the objects graph.

This type is a holder for the initial value only - it is not a live, subscribable view of channel state. The COUNTER_CREATE operation it gives rise to is published when the enclosing mutation is applied.

Instances are obtained via the static create(Number) factory and are immutable after creation. The initial count is held internally by the implementation; it has no public accessor.

Spec: RTLCV1, RTLCV2, RTLCV3

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Extended by the LiveObjects implementation; not intended for application subclassing.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull LiveCounter
    Creates a new LiveCounter value type with an initial count of 0.
    static @NotNull LiveCounter
    create(@NotNull Number initialCount)
    Creates a new LiveCounter value type with the given initial count.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LiveCounter

      protected LiveCounter()
      Extended by the LiveObjects implementation; not intended for application subclassing. Avoids implicit empty public constructor.
  • Method Details

    • create

      @NotNull public static @NotNull LiveCounter create()
      Creates a new LiveCounter value type with an initial count of 0.

      Spec: RTLCV3, RTLCV3a1, RTLCV3b

      Returns:
      an immutable LiveCounter value type
      Throws:
      IllegalStateException - if the LiveObjects plugin is not on the classpath
    • create

      @NotNull public static @NotNull LiveCounter create(@NotNull @NotNull Number initialCount)
      Creates a new LiveCounter value type with the given initial count. No input validation is performed at creation time; validation is deferred to when the value is evaluated by a mutation method.

      Spec: RTLCV3, RTLCV3b, RTLCV3c, RTLCV3d

      Parameters:
      initialCount - the initial count for the new LiveCounter object
      Returns:
      an immutable LiveCounter value type
      Throws:
      IllegalStateException - if the LiveObjects plugin is not on the classpath