Adds a number of convenience methods, and the ability to detect resources with duplicate paths.
-
New methods for converting
*List
classes into aMap
, indexed by name:ClassInfoList#asMap()
MethodInfoList#asMap()
FieldInfoList#asMap()
AnnotationInfoList#asMap()
ResourceList#asMap()
-
New methods for filtering a
ResourceList
for onlyResource
elements with or without a.class
extension respectively:ResourceList#classFilesOnly()
ResourceList#nonClassFilesOnly()
-
New method for detecting resources with duplicate paths across different classpath or module path entries:
ResourceList#findDuplicatePaths()
-- returns aList<Entry<String, ResourceList>>
for all resources with duplicate paths (theEntry
key is the path, and the value is aResourceList
consisting of two or moreResource
elements with that path). Thanks to @vorburger for the suggestion and a code submission for this feature (#256).- e.g. to find duplicate classfiles:
for (Entry<String, ResourceList> dup : new ClassGraph().scan().getAllResources().classFilesOnly().findDuplicatePaths()) { System.out.println(dup.getKey()); for (Resource res : dup.getValue()) { System.out.println(" -> " + res.getURL()); } }
-
Newly deprecated methods:
FieldInfo#getDefiningClass()
-> use insteadFieldInfo#getClassInfo()
FieldInfo#getDefiningClassName()
-> use insteadFieldInfo#getClassInfo().getName()
MethodInfo#getDefiningClass()
-> use insteadMethodInfo#getClassInfo()
MethodInfo#getDefiningClassName()
-> use insteadMethodInfo#getClassInfo().getName()