Package arez

Interface Disposable

All Known Implementing Classes:
Component, ComponentKernel, ComputableValue, DocumentVisibility, MemoizeCache, Node, ObservableValue, Observer, SchedulerLock, Task

public interface Disposable
Interface that allows caller to release any resources associated with element. It is safe to invoke dispose() multiple times on a element. Once an element is disposed, no methods should be invoked on element.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Disposable
    Cast specified object to instance of Disposable.
    void
    Dispose the element.
    static void
    dispose(Object object)
    Dispose the supplied object if it is Disposable, else do nothing.
    boolean
    Return true if dispose() has been called on object.
    static boolean
    Return true if the parameter is Disposable and has been disposed, else return false.
    default boolean
    Return true if isDisposed() returns false.
    static boolean
    Return true if isDisposed(Object) returns false for the same parameter.
  • Method Details

    • dispose

      void dispose()
      Dispose the element. See Disposable for a description of the implications.
    • isDisposed

      boolean isDisposed()
      Return true if dispose() has been called on object.
      Returns:
      true if dispose has been called.
    • isNotDisposed

      default boolean isNotDisposed()
      Return true if isDisposed() returns false.
      Returns:
      true if isDisposed() returns false.
    • dispose

      static void dispose(@Nullable Object object)
      Dispose the supplied object if it is Disposable, else do nothing.
      Parameters:
      object - the object to dispose.
    • isDisposed

      static boolean isDisposed(@Nullable Object object)
      Return true if the parameter is Disposable and has been disposed, else return false.
      Parameters:
      object - the object to check disposed state.
      Returns:
      true if the parameter is Disposable and has been disposed, else return false.
    • isNotDisposed

      static boolean isNotDisposed(@Nullable Object object)
      Return true if isDisposed(Object) returns false for the same parameter.
      Parameters:
      object - the object to check state.
      Returns:
      true if the parameter is not Disposable or has not been disposed, else return false.
    • asDisposable

      @Nonnull static Disposable asDisposable(@Nonnull Object object)
      Cast specified object to instance of Disposable. Invariant checks will verify that the cast is valid before proceeding.
      Parameters:
      object - the object to cast to Disposable.
      Returns:
      the object cast to Disposable.