Class ClassPathScanner
java.lang.Object
tech.guilhermekaua.spigotboot.core.scanner.ClassPathScanner
-
Constructor Summary
ConstructorsConstructorDescriptionClassPathScanner(@NotNull ClassLoader classLoader, @NotNull String... packages) Creates a new ClassPathScanner with the specified class loader. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPackages(@NotNull String... packages) Adds additional packages to scan.voidclear()Clears all cached scanning results.static ClassPathScannerCreates a scanner using the context class loader.Gets all scanned classes.Gets the packages that have been scanned.getSubTypesOf(@NotNull Class<T> superType) Gets all subtypes (subclasses and implementations) of the specified type.getTypesAnnotatedWith(@NotNull Class<? extends Annotation> annotation) Gets all classes annotated with the specified annotation.getTypesAnnotatedWith(@NotNull Class<? extends Annotation> annotation, boolean checkMetaAnnotations) Gets all classes annotated with the specified annotation.
-
Constructor Details
-
ClassPathScanner
public ClassPathScanner(@NotNull @NotNull ClassLoader classLoader, @NotNull @NotNull String... packages) Creates a new ClassPathScanner with the specified class loader.- Parameters:
classLoader- the class loader to use for loading classespackages- the packages to scan (can be empty for lazy scanning)
-
-
Method Details
-
create
Creates a scanner using the context class loader.- Parameters:
packages- the packages to scan- Returns:
- a new ClassPathScanner instance
-
addPackages
Adds additional packages to scan. Classes from these packages will be added to the existing scanned classes.- Parameters:
packages- the packages to add
-
getTypesAnnotatedWith
public Set<Class<?>> getTypesAnnotatedWith(@NotNull @NotNull Class<? extends Annotation> annotation, boolean checkMetaAnnotations) Gets all classes annotated with the specified annotation. This includes classes with meta-annotations (annotations on annotations).- Parameters:
annotation- the annotation class to search forcheckMetaAnnotations- whether to check for meta-annotations- Returns:
- a set of classes annotated with the annotation
-
getTypesAnnotatedWith
public Set<Class<?>> getTypesAnnotatedWith(@NotNull @NotNull Class<? extends Annotation> annotation) Gets all classes annotated with the specified annotation. This includes classes with meta-annotations (annotations on annotations).- Parameters:
annotation- the annotation class to search for- Returns:
- a set of classes annotated with the annotation
-
getSubTypesOf
Gets all subtypes (subclasses and implementations) of the specified type.- Type Parameters:
T- the type parameter- Parameters:
superType- the super type to search for- Returns:
- a set of classes that extend or implement the super type
-
getAllClasses
Gets all scanned classes.- Returns:
- an unmodifiable set of all scanned classes
-
getScannedPackages
Gets the packages that have been scanned.- Returns:
- an unmodifiable set of scanned package names
-
clear
public void clear()Clears all cached scanning results.
-