Class DittoSyncSubscription

java.lang.Object
com.ditto.java.DittoSyncSubscription
All Implemented Interfaces:
Closeable, AutoCloseable

public final class DittoSyncSubscription extends Object implements Closeable
A sync subscription configures Ditto to receive updates from remote peers about documents matching the subscription's query. Create a sync subscription by calling DittoSync.registerSubscription(String). The subscription will remain active until either explicitly cancelled via close() or the owning Ditto instance goes out of scope.
  • Method Details

    • getQuery

      public @NonNull String getQuery()
      Returns the query string for this subscription. Documents matching this query will be included in the subscription.
      Returns:
      the query string.
    • getArguments

      public @Nullable DittoCborSerializable.Dictionary getArguments()
      Returns the query arguments of the sync subscription. These are the arguments that were passed while registering the subscription.
      Returns:
      the query arguments dictionary, or null if no arguments were provided.
    • isClosed

      public boolean isClosed()
      Returns whether the sync subscription has been closed. Returns true if the sync subscription has been cancelled, otherwise returns false. Also, a sync subscription is considered cancelled if the owning Ditto instance goes out of scope.
      Returns:
      true if closed, false otherwise.
    • close

      public void close() throws IOException
      Closes the sync subscription so that new changes matching the query are no longer received from other peers. This is a no-op if the subscription is already closed via a previous call or the owning Ditto instance has gone out of scope.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if an I/O error occurs.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object