ClassLikeFilter extends AbstractLogFilter { protected TreeSet<String> preparePackagesNodes(Set<String> classesSet) { TreeSet<String> packages = new TreeSet<>(); for (String string : classesSet) { Clazz clazz = new Clazz(string); String pack = clazz.pack; int start = 0; while (start < pack.length()) { int idx = pack.indexOf('.', start + 1); if (idx < 0) { idx = pack.length(); } String upClazz = pack.substring(0, idx); packages.add(upClazz); start = idx; } } return packages; } ClassLikeFilter(String name, String description); abstract Function<LogData, String> extractValueFunction(); @Override boolean accept(LogData logData, int row); @Override Component getGUI(); @Override void init(Properties properties, LogDataTableModel collector, Theme theme); @Override void setEnable(boolean enable); void ignoreClass(String... classes); void focusOn(String... classes);  }
@Test public void testPreparePackagesNodes() throws Exception { final HashSet<String> clazzes = new HashSet<>(Arrays.asList("a.b.C", "a.b.D", "c.d.A", "A")); final TreeSet<String> packages = filter.preparePackagesNodes(clazzes); assertEquals(packages.size(), 4); assertEquals(packages, new HashSet<>(Arrays.asList("a", "a.b", "c", "c.d"))); packages.stream().forEach(System.out::println); }