Class ClassFinder


  • public class ClassFinder
    extends Object
    Enables discovery of classes that extend or implement a given class. Instances maintain a cache of search results and should be reused for better performance. The cache is thread-safe but allows for multiple search requests to go through if they arrive at exactly the same time. This class operates in best-effort manner and only logs (never rethrows) any exceptions that occur during the search or class loading.
    • Field Detail

      • CONCRETE

        public static final Predicate<io.github.classgraph.ClassInfo> CONCRETE
      • NON_IGNORED

        public static final Predicate<io.github.classgraph.ClassInfo> NON_IGNORED
      • PUBLIC

        public static final Predicate<io.github.classgraph.ClassInfo> PUBLIC
      • ALL

        public static final Predicate<io.github.classgraph.ClassInfo> ALL
      • log

        public static final org.slf4j.Logger log
    • Constructor Detail

      • ClassFinder

        public ClassFinder()
    • Method Detail

      • findImplementations

        public List<AnnotatedType> findImplementations​(AnnotatedType superType,
                                                       Predicate<io.github.classgraph.ClassInfo> filter,
                                                       boolean allowMissingGenerics,
                                                       String... packages)
        Searches for the implementations/subtypes of the given AnnotatedType. Only the matching classes are loaded.
        Parameters:
        superType - The type the implementations/subtypes of which are to be searched for
        packages - The packages to limit the search to
        Returns:
        A collection of AnnotatedTypes discovered that implementation/extend superType
      • findImplementations

        public List<Class<?>> findImplementations​(Class<?> superType,
                                                  Predicate<io.github.classgraph.ClassInfo> filter,
                                                  String... packages)
        Searches for the implementations/subtypes of the given class. Only the matching classes are loaded.
        Parameters:
        superType - The type the implementations/subtypes of which are to be searched for
        packages - The packages to limit the search to
        Returns:
        A collection of classes discovered that implementation/extend superType
      • close

        public void close()