@Test public void testReturnsSameTabAfterClose() throws IOException { IOTabMaintainer<Integer, Tab> maintainer = create(); String caption = "my-tab"; Tab originalTab; try (IOTabRef<Tab> tabRef = maintainer.getTab(1, caption)) { originalTab = tabRef.getTab(); } assertTrue("Must be closed.", originalTab.isClosedForNow()); assertEquals(caption, originalTab.caption); IOTabRef<Tab> tabRef2 = maintainer.getTab(1, caption); assertSame(originalTab, tabRef2.getTab()); }
public IOTabRef<IOTab> getTab(TabKey key, String caption) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(caption, "caption"); cleanupTabs(); CountedTab<IOTab> result = tryGetAvailable(key); if (result == null) { result = newTabWithContext(key, caption); } else { tabIndexes.incAndGet(key); } return new IOTabRefImpl(key, result); }
IOTabMaintainer { public IOTabRef<IOTab> getTab(TabKey key, String caption) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(caption, "caption"); cleanupTabs(); CountedTab<IOTab> result = tryGetAvailable(key); if (result == null) { result = newTabWithContext(key, caption); } else { tabIndexes.incAndGet(key); } return new IOTabRefImpl(key, result); } }
IOTabMaintainer { public IOTabRef<IOTab> getTab(TabKey key, String caption) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(caption, "caption"); cleanupTabs(); CountedTab<IOTab> result = tryGetAvailable(key); if (result == null) { result = newTabWithContext(key, caption); } else { tabIndexes.incAndGet(key); } return new IOTabRefImpl(key, result); } IOTabMaintainer(IOTabFactory<? extends IOTab> factory); }
IOTabMaintainer { public IOTabRef<IOTab> getTab(TabKey key, String caption) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(caption, "caption"); cleanupTabs(); CountedTab<IOTab> result = tryGetAvailable(key); if (result == null) { result = newTabWithContext(key, caption); } else { tabIndexes.incAndGet(key); } return new IOTabRefImpl(key, result); } IOTabMaintainer(IOTabFactory<? extends IOTab> factory); IOTabRef<IOTab> getNewTab(TabKey key, String caption); IOTabRef<IOTab> getTab(TabKey key, String caption); }
IOTabMaintainer { public IOTabRef<IOTab> getTab(TabKey key, String caption) { Objects.requireNonNull(key, "key"); Objects.requireNonNull(caption, "caption"); cleanupTabs(); CountedTab<IOTab> result = tryGetAvailable(key); if (result == null) { result = newTabWithContext(key, caption); } else { tabIndexes.incAndGet(key); } return new IOTabRefImpl(key, result); } IOTabMaintainer(IOTabFactory<? extends IOTab> factory); IOTabRef<IOTab> getNewTab(TabKey key, String caption); IOTabRef<IOTab> getTab(TabKey key, String caption);  }