/** * @return A {@link List} of {@link Entry} objects for all resources in the classpath and/or module path that * have a non-unique path (i.e. where there are at least two resources with the same path). The key of * each returned {@link Entry} is the path (obtained from {@link Resource#getPath()}), and the value is * a {@link ResourceList} of at least two unique {@link Resource} objects that have that path. */ public List<Entry<String, ResourceList>> findDuplicatePaths() { final List<Entry<String, ResourceList>> duplicatePaths = new ArrayList<>(); for (final Entry<String, ResourceList> pathAndResourceList : asMap().entrySet()) { // Find ResourceLists with two or more entries if (pathAndResourceList.getValue().size() > 1) { duplicatePaths.add(new SimpleEntry<>(pathAndResourceList.getKey(), pathAndResourceList.getValue())); } } Collections.sort(duplicatePaths, new Comparator<Entry<String, ResourceList>>() { @Override public int compare(final Entry<String, ResourceList> o1, final Entry<String, ResourceList> o2) { // Sort in lexicographic order of path return o1.getKey().compareTo(o2.getKey()); } }); return duplicatePaths; }