@Test public void testReturnsDifferentTabForDifferentKeys() throws IOException { IOTabMaintainer<Integer, Tab> maintainer = create(); Tab tab1; IOTabRef<Tab> tabRef2; Tab tab2; try (IOTabRef<Tab> tabRef1 = maintainer.getTab(1, "tab1")) { tab1 = tabRef1.getTab(); tabRef2 = maintainer.getTab(2, "tab2"); tab2 = tabRef2.getTab(); } tabRef2.close(); Tab tab3; try (IOTabRef<Tab> tabRef3 = maintainer.getTab(3, "tab3")) { tab3 = tabRef3.getTab(); } assertEquals("tab1", tab1.caption); assertEquals("tab2", tab2.caption); assertEquals("tab3", tab3.caption); }
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);  }