Interface ClassFinder


public interface ClassFinder
An interface to find classes on the class-path.
  • Method Details

    • findMatchingClasses

      Stream<Class<?>> findMatchingClasses(Predicate<Class<?>> query)
      Returns a stream of classes on the class-path, each of which matches the query.
      Parameters:
      query - A query to check if a given class matches.
      Returns:
      A stream of matching classes.
    • create

      static ClassFinder create(String rootPackage)
      Returns a ClassFinder, which checks all the classes under rootPackage with a given query predicate.
      Parameters:
      rootPackage - A root package.
      Returns:
      A new ClassFinder object.
    • classNameIsEqualTo

      static Predicate<Class<?>> classNameIsEqualTo(String value)
      A utility method to return a Predicate, which can be used with findMatchingClasses method.
      Parameters:
      value - A string value from which the returned predicate is created.
      Returns:
      A predicate which matches a class whose name is equal to value.
    • classNameContaining

      static Predicate<Class<?>> classNameContaining(String value)
      A utility method to return a Predicate, which can be used with findMatchingClasses method.
      Parameters:
      value - A string value from which the returned predicate is created.
      Returns:
      A predicate which matches a class whose name is containing value.
    • classNameMatchesRegex

      static Predicate<Class<?>> classNameMatchesRegex(String value)
      A utility method to return a Predicate, which can be used with findMatchingClasses method.
      Parameters:
      value - A string value from which the returned predicate is created.
      Returns:
      A predicate which matches a class whose name matches a regular expression value.
    • alwaysTrue

      static Predicate<Class<?>> alwaysTrue()
      A utility method to return a Predicate, which can be used with findMatchingClasses method.
      Returns:
      A predicate which matches any class.
    • isAssignableTo

      static Predicate<Class<?>> isAssignableTo(Class<?> klass)
      A utility method to return a Predicate, which can be used with findMatchingClasses method.
      Parameters:
      klass - A class object from which the returned predicate is created.
      Returns:
      A predicate which matches a class which is assignable from klass.
    • hasAnnotations

      @SafeVarargs static Predicate<Class<?>> hasAnnotations(Class<? extends Annotation>... annotationClasses)
      A utility method to return a Predicate, which can be used with findMatchingClasses method.
      Parameters:
      annotationClasses - classes from which the returned predicate is created.
      Returns:
      A predicate which matches any of annotationClasses is present.
    • hasTagValueEqualTo

      static Predicate<Class<?>> hasTagValueEqualTo(String value)
      A utility method to return a Predicate, which can be used with findMatchingClasses method.
      Parameters:
      value - A string value from which the returned predicate is created.
      Returns:
      A predicate which matches a class whose @Tag annotation value is equal to value.
    • hasTagValueContaining

      static Predicate<Class<?>> hasTagValueContaining(String value)
    • hasTagValueMatchesRegex

      static Predicate<Class<?>> hasTagValueMatchesRegex(String value)
    • functionSimpleName

      static Function<Class<?>,String> functionSimpleName()