public static void register( @NotNull Disposable parent, @NotNull Disposable child, @NonNls @Nullable final String key) { assert parent != child : " Cannot register to itself"; ourTree.register(parent, child); if (key != null) { assert get(key) == null; ourKeyDisposables.put(key, child); register( child, new Disposable() { @Override public void dispose() { ourKeyDisposables.remove(key); } }); } }
/** * @return object registered on parentDisposable which is equal to object, or null if not found */ @Nullable public static <T extends Disposable> T findRegisteredObject( @NotNull Disposable parentDisposable, @NotNull T object) { return ourTree.findRegisteredObject(parentDisposable, object); }
@TestOnly public static boolean isEmpty() { return ourDebugMode && ourTree.isEmpty(); }
public static void assertIsEmpty(boolean throwError) { if (ourDebugMode) { ourTree.assertIsEmpty(throwError); } }
public static void disposeChildAndReplace( @NotNull Disposable toDispose, @NotNull Disposable toReplace) { ourTree.executeChildAndReplace(toDispose, toReplace, true, ourDisposeAction); }
public static void dispose(@NotNull Disposable disposable, boolean processUnregistered) { ourTree.executeAll(disposable, true, ourDisposeAction, processUnregistered); }
public static boolean isDisposed(@NotNull Disposable disposable) { return ourTree.getDisposalInfo(disposable) != null; }