Interface ClassFinder

All Superinterfaces:
Serializable
All Known Implementing Classes:
ClassFinder.CachedClassFinder, ClassFinder.DefaultClassFinder

public interface ClassFinder extends Serializable
Interface for annotated and subclass class searches.

For internal use only. May be renamed or removed in a future release.

Since:
2.0.3
  • Method Details

    • getAnnotatedClasses

      Set<Class<?>> getAnnotatedClasses(Class<? extends Annotation> clazz)
      Get annotated classes in the classloader.
      Parameters:
      clazz - the annotation
      Returns:
      a set with all classes that are annotated
    • getAnnotatedClasses

      default Set<Class<?>> getAnnotatedClasses(String className) throws ClassNotFoundException
      Get annotated classes in the classloader.
      Parameters:
      className - the annotation class name
      Returns:
      a set with all classes that are annotated
      Throws:
      ClassNotFoundException - when the class not found
    • getResource

      URL getResource(String name)
      Get a resource from the classpath.
      Parameters:
      name - class literal
      Returns:
      the resource
    • getResources

      default List<URL> getResources(String name) throws IOException
      Get all resources with the given name from the classpath.

      Unlike getResource(String), which returns only the first match, this returns the resource from every jar or folder providing it.

      Parameters:
      name - the resource path
      Returns:
      all matching resources, never null
      Throws:
      IOException - if the resources cannot be listed
    • loadClass

      <T> Class<T> loadClass(String name) throws ClassNotFoundException
      Load a class in the classloader.
      Type Parameters:
      T - the type of the class
      Parameters:
      name - the class literal
      Returns:
      the class
      Throws:
      ClassNotFoundException - when the class is not in the classpath
    • getSubTypesOf

      <T> Set<Class<? extends T>> getSubTypesOf(Class<T> type)
      Gets all subtypes in hierarchy of a given type.
      Type Parameters:
      T - the class of the type
      Parameters:
      type - the type to search for the subtypes for
      Returns:
      set of the subtypes of the given class
    • getClassLoader

      ClassLoader getClassLoader()
      Get class loader which is used to find classes.
      Returns:
      the class loader which is used to find classes..
      Since:
      3.0
    • getSubTypesOf

      default <T> Set<Class<? extends T>> getSubTypesOf(String name) throws ClassNotFoundException
      Gets all subtypes in hierarchy of a given type, using FQN string.
      Type Parameters:
      T - the class of the type
      Parameters:
      name - Fully qualified name of the type to search subtypes of
      Returns:
      set of the subtypes of the given class
      Throws:
      ClassNotFoundException - when the parent class is not in the classpath
    • shouldInspectClass

      default boolean shouldInspectClass(String className)
      Determines whether the specified class should be inspected for Vaadin-related resources.

      The default implementation always returns true, meaning all classes are considered inspectable. Implementations may override this method to provide custom filtering logic.

      Parameters:
      className - the fully qualified name of the class
      Returns:
      true if the class should be inspected, otherwise false
      Since:
      24.8