Interface AsyncDistributedSet<E>

  • Type Parameters:
    E - set entry type
    All Superinterfaces:
    DistributedPrimitive

    public interface AsyncDistributedSet<E>
    extends DistributedPrimitive
    A distributed collection designed for holding unique elements.

    All methods of AsyncDistributedSet immediately return a future. The returned future will be completed when the operation completes.

    • Method Detail

      • addListener

        CompletableFuture<Void> addListener​(SetEventListener<E> listener)
        Registers the specified listener to be notified whenever the set is updated.
        Parameters:
        listener - listener to notify about set update events
        Returns:
        CompletableFuture that is completed when the operation completes
      • removeListener

        CompletableFuture<Void> removeListener​(SetEventListener<E> listener)
        Unregisters the specified listener.
        Parameters:
        listener - listener to unregister.
        Returns:
        CompletableFuture that is completed when the operation completes
      • add

        CompletableFuture<Boolean> add​(E element)
        Adds the specified element to this set if it is not already present (optional operation).
        Parameters:
        element - element to add
        Returns:
        true if this set did not already contain the specified element.
      • remove

        CompletableFuture<Boolean> remove​(E element)
        Removes the specified element to this set if it is present (optional operation).
        Parameters:
        element - element to remove
        Returns:
        true if this set contained the specified element
      • clear

        CompletableFuture<Void> clear()
        Removes all elements from the set.
        Returns:
        CompletableFuture that is completed when the operation completes
      • contains

        CompletableFuture<Boolean> contains​(E element)
        Returns if this set contains the specified element.
        Parameters:
        element - element to check
        Returns:
        true if this set contains the specified element
      • addAll

        CompletableFuture<Boolean> addAll​(Collection<? extends E> c)
        Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
        Parameters:
        c - collection containing elements to be added to this set
        Returns:
        true if this set contains all elements in the collection
      • containsAll

        CompletableFuture<Boolean> containsAll​(Collection<? extends E> c)
        Returns if this set contains all the elements in specified collection.
        Parameters:
        c - collection
        Returns:
        true if this set contains all elements in the collection
      • retainAll

        CompletableFuture<Boolean> retainAll​(Collection<? extends E> c)
        Retains only the elements in this set that are contained in the specified collection (optional operation).
        Parameters:
        c - collection containing elements to be retained in this set
        Returns:
        true if this set changed as a result of the call
      • removeAll

        CompletableFuture<Boolean> removeAll​(Collection<? extends E> c)
        Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.
        Parameters:
        c - collection containing elements to be removed from this set
        Returns:
        true if this set changed as a result of the call
      • asDistributedSet

        default DistributedSet<E> asDistributedSet()
        Returns a new DistributedSet that is backed by this instance.
        Returns:
        new DistributedSet instance
      • asDistributedSet

        default DistributedSet<E> asDistributedSet​(long timeoutMillis)
        Returns a new DistributedSet that is backed by this instance.
        Parameters:
        timeoutMillis - timeout duration for the returned DistributedSet operations
        Returns:
        new DistributedSet instance
      • getAsImmutableSet

        CompletableFuture<? extends Set<E>> getAsImmutableSet()
        Returns the entries as a immutable set. The returned set is a snapshot and will not reflect new changes made to this AsyncDistributedSet
        Returns:
        immutable set copy