XLogUtils { public static List<String> getPkgPrefixesForCoarseMatch(List<String> classNames, int pkgSectionSize) { if (pkgSectionSize <= 0) { return classNames; } List<String> result = new ArrayList<String>(); if (classNames != null) { for (String className : classNames) { if (getClassNameSectionSize(className) < pkgSectionSize) { if (!result.contains(className)) { result.add(className); } } else { String prefix = getClassNameSection(className, pkgSectionSize); if (!result.contains(prefix)) { result.add(prefix); } } } } Set<String> names = new HashSet<String>(result); Iterator<String> iterator = result.iterator(); while (iterator.hasNext()) { String className = iterator.next(); for (String s : names) { if (className.startsWith(s) && !className.equals(s)) { iterator.remove(); } } } return result; } private  XLogUtils(); static Set<String> getRemainingClassNames(Set<Class<?>> classes,
            Set<String> classNames); static boolean shouldLogMember(List<XLogMethod> xLogMethods, Member member); static boolean filterResult(String className, XLogSetting xLogSetting); static List<String> getPkgPrefixesForCoarseMatch(List<String> classNames,
            int pkgSectionSize); static List<String> getPkgPrefixesForCoarseMatchXLogMethods(List<XLogMethod> xLogMethods,
            int pkgSectionSize); static final int TYPE_METHOD; static final int TYPE_CONSTRUCTOR; static final String PKG_NAME; static final String CLASS_NAME; static final String FIELD_NAME_METHODS; static final String FIELD_NAME_CLASSES; }
@Test public void testGetPkgPrefixesForCoarseMatch1() { assertThat(XLogUtils.getPkgPrefixesForCoarseMatch(new ArrayList<String>(), 1).size(), is(0)); }
@Test public void testGetPkgPrefixesForCoarseMatch2() { assertThat(XLogUtils.getPkgPrefixesForCoarseMatch(CLASS_NAMES, -1).size(), is(CLASS_NAMES.size())); assertThat(XLogUtils.getPkgPrefixesForCoarseMatch(CLASS_NAMES, 0).size(), is(CLASS_NAMES.size())); }
@Test public void testGetPkgPrefixesForCoarseMatch3() { List<String> expected = new ArrayList<String>(); expected.add("com.promegu"); expected.add("java.lang"); expected.add("retrofit"); assertThat(XLogUtils.getPkgPrefixesForCoarseMatch(CLASS_NAMES, 2), is(expected)); expected.clear(); expected.add("com.promegu.xlog"); expected.add("com.promegu.other"); expected.add("java.lang.Object"); expected.add("java.lang.test"); expected.add("retrofit"); assertThat(XLogUtils.getPkgPrefixesForCoarseMatch(CLASS_NAMES, 3), is(expected)); }