com.vaadin.flow.server.frontend.scanner.
Class ClassFinder.DefaultClassFinder
- java.lang.Object
-
- com.vaadin.flow.server.frontend.scanner.ClassFinder.DefaultClassFinder
-
All Implemented Interfaces:
Enclosing interface:
public static class ClassFinder.DefaultClassFinder extends Object implements ClassFinder
Implementation that searches for annotated classes or subclasses in a list of classes.
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.flow.server.frontend.scanner.ClassFinder
ClassFinder.CachedClassFinder, ClassFinder.DefaultClassFinder
-
-
Constructor Summary
Constructors Constructor Description DefaultClassFinder(ClassLoader classLoader, Class<?>... classes)
ClassFinder using a specified
ClassLoader
to load classes and a list of classes where to look for annotations or subclasses.DefaultClassFinder(Set<Class<?>> classes)
It uses current classloader for getting resources or loading classes.
-
Method Summary
All Methods Modifier and Type Method Description Set<Class<?>>
getAnnotatedClasses(Class<? extends Annotation> annotation)
Get annotated classes in the classloader.
ClassLoader
getClassLoader()
Get class loader which is used to find classes.
URL
getResource(String name)
Get a resource from the classpath.
<T> Set<Class<? extends T>>
getSubTypesOf(Class<T> type)
Gets all subtypes in hierarchy of a given type.
<T> Class<T>
loadClass(String name)
Load a class in the classloader.
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.server.frontend.scanner.ClassFinder
getAnnotatedClasses, getSubTypesOf
-
-
-
-
Constructor Detail
-
DefaultClassFinder
public DefaultClassFinder(Set<Class<?>> classes)
It uses current classloader for getting resources or loading classes.
Parameters:
classes
- The classes.
-
DefaultClassFinder
public DefaultClassFinder(ClassLoader classLoader, Class<?>... classes)
ClassFinder using a specified
ClassLoader
to load classes and a list of classes where to look for annotations or subclasses.Parameters:
classLoader
- classloader for getting resources or loading classes.classes
- classes where to look for annotations or subclasses.
-
-
Method Detail
-
getAnnotatedClasses
public Set<Class<?>> getAnnotatedClasses(Class<? extends Annotation> annotation)
Description copied from interface:
ClassFinder
Get annotated classes in the classloader.
Specified by:
getAnnotatedClasses
in interfaceClassFinder
Parameters:
annotation
- the annotationReturns:
a set with all classes that are annotated
-
getResource
public URL getResource(String name)
Description copied from interface:
ClassFinder
Get a resource from the classpath.
Specified by:
getResource
in interfaceClassFinder
Parameters:
name
- class literalReturns:
the resource
-
loadClass
public <T> Class<T> loadClass(String name) throws ClassNotFoundException
Description copied from interface:
ClassFinder
Load a class in the classloader.
Specified by:
loadClass
in interfaceClassFinder
Parameters:
name
- the class literalReturns:
the class
Throws:
ClassNotFoundException
- when the class is not in the classpath
-
getSubTypesOf
public <T> Set<Class<? extends T>> getSubTypesOf(Class<T> type)
Description copied from interface:
ClassFinder
Gets all subtypes in hierarchy of a given type.
Specified by:
getSubTypesOf
in interfaceClassFinder
Type Parameters:
T
- the class of the typeParameters:
type
- the type to search for the subtypes forReturns:
set of the subtypes of the given class
-
getClassLoader
public ClassLoader getClassLoader()
Description copied from interface:
ClassFinder
Get class loader which is used to find classes.
Specified by:
getClassLoader
in interfaceClassFinder
Returns:
the class loader which is used to find classes..
-
-