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