class 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)) {
                    // there is a B in result list which is the prefix of A, should remove A
                    iterator.remove();
                }
            }
        }

        return result;
    }

    private  XLogUtils();

}