Class ItemListDisposable<T>

java.lang.Object
org.fulib.fx.data.disposable.ItemListDisposable<T>
Type Parameters:
T - the type of the items
All Implemented Interfaces:
io.reactivex.rxjava3.disposables.Disposable, RefreshableDisposable

public class ItemListDisposable<T> extends Object implements RefreshableDisposable
A disposable which disposes a list of items when it is disposed.

The items are disposed in reverse order, so the last item is disposed first (LIFO).

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T item)
    Adds an item to the list of items to dispose.
    void
     
    boolean
     
    boolean
    Returns true if the disposable is not disposed and clean.
    static <T> ItemListDisposable<T>
    of(Consumer<T> onDispose, List<T> toDispose)
    Creates a new disposable which disposes all items in the list with the given action when it is disposed.
    static <T> ItemListDisposable<T>
    of(Consumer<T> onDispose, T... toDispose)
    Creates a new disposable which disposes all items in the list with the given action when it is disposed.
    boolean
    Refreshes the disposable if it is disposed.

    Methods inherited from class java.lang.Object

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

    • of

      @SafeVarargs public static <T> ItemListDisposable<T> of(Consumer<T> onDispose, T... toDispose)
      Creates a new disposable which disposes all items in the list with the given action when it is disposed.
      Type Parameters:
      T - the type of the items
      Parameters:
      onDispose - the action to execute for an item when the disposable is disposed
      toDispose - the items to dispose
      Returns:
      the disposable
    • of

      public static <T> ItemListDisposable<T> of(Consumer<T> onDispose, List<T> toDispose)
      Creates a new disposable which disposes all items in the list with the given action when it is disposed.
      Type Parameters:
      T - the type of the items
      Parameters:
      onDispose - the action to execute for an item when the disposable is disposed
      toDispose - the items to dispose
      Returns:
      the disposable
    • dispose

      public void dispose()
      Specified by:
      dispose in interface io.reactivex.rxjava3.disposables.Disposable
    • isDisposed

      public boolean isDisposed()
      Specified by:
      isDisposed in interface io.reactivex.rxjava3.disposables.Disposable
    • refresh

      public boolean refresh()
      Description copied from interface: RefreshableDisposable
      Refreshes the disposable if it is disposed. If the disposable is not disposed (or not initialized), this method does nothing.
      Specified by:
      refresh in interface RefreshableDisposable
      Returns:
      true if the disposable can now be reused, false otherwise
    • isFresh

      public boolean isFresh()
      Description copied from interface: RefreshableDisposable
      Returns true if the disposable is not disposed and clean.
      Specified by:
      isFresh in interface RefreshableDisposable
      Returns:
      true if the disposable is not disposed and clean, false otherwise
    • add

      public void add(T item)
      Adds an item to the list of items to dispose.
      Parameters:
      item - the item to dispose