public class AnnotationUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
AnnotationUtils.MethodFilter
Enumerates applicable method filters.
|
| Modifier and Type | Method and Description |
|---|---|
static Set<String> |
findClassesWithAnnotation(Class<? extends Annotation> annotationClass,
String basePackage)
Scans the class path from a base package to find classes annotated with a given
annotation.
|
static Method |
getSinglePublicMethodWithAnnotation(Class<? extends Annotation> annotationClass,
Class<?> sourceClass)
Returns the public method of the given class that is annotated with the given
annotation, provided that only a single method containing this annotation exists in the
class.
|
static Method |
getSinglePublicMethodWithAnnotation(Class<? extends Annotation> annotationClass,
Class<?> sourceClass,
AnnotationUtils.MethodFilter methodFilter)
Returns the public method of the given class that is annotated with the given
annotation, provided that only a single method containing this annotation exists in the
class.
|
public static Method getSinglePublicMethodWithAnnotation(Class<? extends Annotation> annotationClass, Class<?> sourceClass)
Note: This has the same effect as calling:
getSinglePublicMethodWithAnnotation(annotationClass, sourceClass, MethodFilter.DEFAULT);
annotationClass - the Annotation class that must be present on a method to
be matched, not nullsourceClass - the Class to query, not nullMethod which is annotated with the specified annotationNullPointerException - if either of the class parameters is nullInvalidClassException - if either no method or more than one method foundpublic static Method getSinglePublicMethodWithAnnotation(Class<? extends Annotation> annotationClass, Class<?> sourceClass, AnnotationUtils.MethodFilter methodFilter)
annotationClass - the Annotation class that must be present on a method to
be matched, not nullsourceClass - the Class to query, not nullmethodFilter - the AnnotationUtils.MethodFilter to apply; null is allowed and
it defaults to AnnotationUtils.MethodFilter.DEFAULTMethod which is annotated with the specified annotationNullPointerException - if either of the class parameters is nullInvalidClassException - if either no method or more than one method found, or if
the method does not match the rules of the specified
AnnotationUtils.MethodFilterpublic static Set<String> findClassesWithAnnotation(Class<? extends Annotation> annotationClass, String basePackage)
annotationClass - the annotation to be filterbasePackage - the package to search for annotated classesCopyright © 2022. All rights reserved.