void () { Disposable parent = Disposer.newDisposable("parent"); Disposable child1 = Disposer.newDisposable("child1"); Disposable child2 = Disposer.newDisposable("child2"); Disposer.register(parent, child1); Disposer.register(parent, child2); Disposable grand1 = Disposer.newDisposable("grand1"); Disposer.register(child1, grand1); try { Disposer.disposeChildren(parent, disposable -> disposable == child1); assertFalse(Disposer.isDisposed(parent)); assertFalse(Disposer.isDisposed(child2)); Disposer.dispose(parent); assertTrue(Disposer.isDisposed(parent)); } finally { Disposer.dispose(grand1); Disposer.dispose(child1); Disposer.dispose(child2); Disposer.dispose(parent); } }