ClassWrapperRenderer implements TableCellRenderer { protected String abbreviatePackageUsingMappings(String clazz, SortedMap<String, String> abbreviations) { for (String s : abbreviations.keySet()) { if (StringUtils.startsWith(clazz,s)) { return StringUtils.replaceOnce(clazz, s, abbreviations.get(s)); } } return clazz; } ClassWrapperRenderer(); @Override Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column); String abbreviatePackagesToSingleLetter(String abbreviatePackage, int availableWidth, FontMetrics fm); void reloadConfiguration(String propertyConfiguration);  }
@Test public void testAbbreviatePackageUsingMappings(){ SortedMap<String, String> map = underTest.toMap("com.company={D}\ncom={E}\ncom.company.package={C}"); final String actual = underTest.abbreviatePackageUsingMappings("com.company.package.Class", map); assertEquals(actual,"{C}.Class"); }