void () { DisposableWrapperList<String> l = new DisposableWrapperList<>(); assertTrue(l.add("a")); assertTrue(l.add("b")); Disposable d1 = Disposer.newDisposable(); assertNotNull(l.add("c", d1)); Disposable d2 = Disposer.newDisposable(); l.add(1, "d", d2); assertEquals(0, l.indexOf("a")); assertEquals(1, l.lastIndexOf("d")); assertEquals("b", l.get(2)); assertEquals("c", l.get(3)); assertEquals(4, l.size()); assertEquals("[a, d, b, c]", Arrays.toString(ArrayUtilRt.toStringArray(l))); Disposer.dispose(d2); assertFalse(l.contains("d")); assertEquals(3, l.size()); assertTrue(l.remove("a")); assertFalse(l.contains("a")); l.clear(); assertTrue(l.isEmpty()); Disposer.dispose(d1); // Cleanup after ourselves. }