Class ClassPathScanner

java.lang.Object
tech.guilhermekaua.spigotboot.core.scanner.ClassPathScanner

public class ClassPathScanner extends Object
  • 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 classes
      packages - the packages to scan (can be empty for lazy scanning)
  • Method Details

    • create

      public static ClassPathScanner create(@NotNull @NotNull String... packages)
      Creates a scanner using the context class loader.
      Parameters:
      packages - the packages to scan
      Returns:
      a new ClassPathScanner instance
    • addPackages

      public void addPackages(@NotNull @NotNull String... packages)
      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 for
      checkMetaAnnotations - 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

      public <T> Set<Class<? extends T>> getSubTypesOf(@NotNull @NotNull Class<T> superType)
      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

      public Set<Class<?>> getAllClasses()
      Gets all scanned classes.
      Returns:
      an unmodifiable set of all scanned classes
    • getScannedPackages

      public Set<String> 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.