Class CompositeDisposable

    • Constructor Detail

      • CompositeDisposable

        public CompositeDisposable()
        Creates an empty CompositeDisposable.
      • CompositeDisposable

        public CompositeDisposable​(@NonNull
                                   @NonNull Disposable... disposables)
        Creates a CompositeDisposable with the given array of initial Disposable elements.
        Parameters:
        disposables - the array of Disposables to start with
        Throws:
        java.lang.NullPointerException - if disposables or any of its array items is null
      • CompositeDisposable

        public CompositeDisposable​(@NonNull
                                   @NonNull java.lang.Iterable<? extends Disposable> disposables)
        Creates a CompositeDisposable with the given Iterable sequence of initial Disposable elements.
        Parameters:
        disposables - the Iterable sequence of Disposable to start with
        Throws:
        java.lang.NullPointerException - if disposables or any of its items is null
    • Method Detail

      • dispose

        public void dispose()
        Description copied from interface: Disposable
        Dispose the resource, the operation should be idempotent.
        Specified by:
        dispose in interface Disposable
      • isDisposed

        public boolean isDisposed()
        Description copied from interface: Disposable
        Returns true if this resource has been disposed.
        Specified by:
        isDisposed in interface Disposable
        Returns:
        true if this resource has been disposed
      • add

        public boolean add​(@NonNull
                           @NonNull Disposable disposable)
        Adds a Disposable to this container or disposes it if the container has been disposed.
        Specified by:
        add in interface DisposableContainer
        Parameters:
        disposable - the Disposable to add, not null
        Returns:
        true if successful, false if this container has been disposed
        Throws:
        java.lang.NullPointerException - if disposable is null
      • addAll

        public boolean addAll​(@NonNull
                              @NonNull Disposable... disposables)
        Atomically adds the given array of Disposables to the container or disposes them all if the container has been disposed.
        Parameters:
        disposables - the array of Disposables
        Returns:
        true if the operation was successful, false if the container has been disposed
        Throws:
        java.lang.NullPointerException - if disposables or any of its array items is null
      • remove

        public boolean remove​(@NonNull
                              @NonNull Disposable disposable)
        Removes and disposes the given Disposable if it is part of this container.
        Specified by:
        remove in interface DisposableContainer
        Parameters:
        disposable - the disposable to remove and dispose, not null
        Returns:
        true if the operation was successful
        Throws:
        java.lang.NullPointerException - if disposable is null
      • delete

        public boolean delete​(@NonNull
                              @NonNull Disposable disposable)
        Removes (but does not dispose) the given Disposable if it is part of this container.
        Specified by:
        delete in interface DisposableContainer
        Parameters:
        disposable - the disposable to remove, not null
        Returns:
        true if the operation was successful
        Throws:
        java.lang.NullPointerException - if disposable is null
      • clear

        public void clear()
        Atomically clears the container, then disposes all the previously contained Disposables.
      • size

        public int size()
        Returns the number of currently held Disposables.
        Returns:
        the number of currently held Disposables