Class AnnotatedClassFinder
- java.lang.Object
- org.springframework.boot.test.context.AnnotatedClassFinder
public final class AnnotatedClassFinder extends Object
Utility class to find a class annotated with a particular annotation in a hierarchy.- Since:
- 2.1.0
Constructor Summary
Constructors Constructor Description AnnotatedClassFinder(Class<? extends Annotation> annotationType)
Create a new instance with theannotationType
to find.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<?>
findFromClass(Class<?> source)
Find the firstClass
that is annotated with the target annotation, starting from the package defined by the givensource
up to the root.Class<?>
findFromPackage(String source)
Find the firstClass
that is annotated with the target annotation, starting from the package defined by the givensource
up to the root.
Constructor Detail
AnnotatedClassFinder
public AnnotatedClassFinder(Class<? extends Annotation> annotationType)
Create a new instance with theannotationType
to find.- Parameters:
annotationType
- the annotation to find
Method Detail
findFromClass
public Class<?> findFromClass(Class<?> source)
Find the firstClass
that is annotated with the target annotation, starting from the package defined by the givensource
up to the root.- Parameters:
source
- the source class to use to initiate the search- Returns:
- the first
Class
annotated with the target annotation within the hierarchy defined by the givensource
ornull
if none is found.
findFromPackage
public Class<?> findFromPackage(String source)
Find the firstClass
that is annotated with the target annotation, starting from the package defined by the givensource
up to the root.- Parameters:
source
- the source package to use to initiate the search- Returns:
- the first
Class
annotated with the target annotation within the hierarchy defined by the givensource
ornull
if none is found.