Package io.hawt.util.introspect.support
Class ClassScanner
java.lang.Object
io.hawt.util.introspect.support.ClassScanner
A helper class to scan classes on the classpath
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddClassesForPackage(ClassResource classResource, String filter, Integer limit, Set<Class<?>> classes) protected voidaddClassNamesInDirectoryWithMethodsAnnotatedWith(SortedSet<String> answer, File dir, Class<? extends Annotation> annotationClass, String packageName) protected voidaddPackageResources(Package aPackage, Map<String, ClassResource> urlSet, ClassLoader[] classLoaders) protected booleanclassNameMatches(String className, String search) Returns true if the given class name matches the filter searchvoidprotected CacheValuecreateCacheValue(String key, ClassResource classResource) Class<?>Finds a class from its namefindClassNames(String search, Integer limit) Searches for the available class names given the text searchfindClassNames(Map<Package, ClassLoader[]> packages, Predicate<String> filter, Integer limit) findClassNamesInDirectoryWithMethodAnnotatedWith(File dir, String annotationClassName) findClassNamesInPackages(String search, Integer limit, Map<Package, ClassLoader[]> packages) findClassNamesMethodsAnnotatedWith(String annotationClassName) findClassNamesMethodsAnnotatedWith(String annotationClassName, Integer limit, Map<Package, ClassLoader[]> packages) Returns all the classes found in a sorted mapgetClassesForPackage(ClassResource classResource, String filter, Integer limit) getClassesMap(Package... packages) Returns all the classes found in a sorted map for the given list of packagesprotected StringgetJavaResourceKey(URL resource) protected StringgetPackageRelativePath(String packageName) getResources(String relPath, ClassLoader... classLoaders) static ClassScannerprotected Class<? extends Annotation>optionallyFindAnnotationClass(String annotationClassName) Class<?>optionallyFindClass(String className) Returns the given class or null if it cannot be loadedoptionallyFindClasses(Iterable<String> classNames) Tries to find as many of the class names on the class loaders as possible and return themprotected voidprocessDirectory(File directory, String packageName, Set<Class<?>> classes, String filter, Integer limit) protected voidprocessDirectoryClassNames(File directory, String packageName, Set<String> classes) protected voidprocessJar(ClassResource classResource, Set<Class<?>> classes, String filter, Integer limit) protected voidprocessJarClassNames(ClassResource classResource, Set<String> classes) voidsetClassLoaderProvider(String id, ClassLoaderProvider classLoaderProvider) Registers a named class loader provider or removes it if the classLoaderProvider is nullvoidsetIgnorePackages(Set<String> ignorePackages) protected Class<?>tryFindClass(String className, String filter) protected booleanwithinLimit(Integer limit, Collection<?> collection) Returns true if we are within the limit value for the number of results in the collection
-
Constructor Details
-
ClassScanner
-
-
Method Details
-
newInstance
-
clearCache
public void clearCache() -
setClassLoaderProvider
Registers a named class loader provider or removes it if the classLoaderProvider is null -
findClassNames
Searches for the available class names given the text search- Returns:
- all the class names found on the current classpath using the given text search filter
-
findClassNamesMethodsAnnotatedWith
-
findClassNamesInDirectoryWithMethodAnnotatedWith
-
addClassNamesInDirectoryWithMethodsAnnotatedWith
-
optionallyFindAnnotationClass
-
findClassNamesMethodsAnnotatedWith
-
findClassNamesInPackages
-
findClassNames
-
getAllClassesMap
Returns all the classes found in a sorted map -
getClassesMap
Returns all the classes found in a sorted map for the given list of packages -
getClassesForPackage
public Set<Class<?>> getClassesForPackage(ClassResource classResource, String filter, Integer limit) -
findClass
Finds a class from its name- Throws:
ClassNotFoundException
-
optionallyFindClass
Returns the given class or null if it cannot be loaded -
optionallyFindClasses
Tries to find as many of the class names on the class loaders as possible and return them -
getIgnorePackages
-
setIgnorePackages
-
addPackageResources
protected void addPackageResources(Package aPackage, Map<String, ClassResource> urlSet, ClassLoader[] classLoaders) -
createCacheValue
-
processDirectoryClassNames
-
processJarClassNames
-
addClassesForPackage
protected void addClassesForPackage(ClassResource classResource, String filter, Integer limit, Set<Class<?>> classes) -
processDirectory
-
processJar
protected void processJar(ClassResource classResource, Set<Class<?>> classes, String filter, Integer limit) -
getJavaResourceKey
-
tryFindClass
-
getResources
-
classNameMatches
Returns true if the given class name matches the filter search -
getPackageRelativePath
-
withinLimit
Returns true if we are within the limit value for the number of results in the collection -
getClassLoaders
-