/**
* The default implementation performs a simple search for a declared annotation matching the search type.
* Spring provides a more sophisticated annotation search utility that matches on meta-annotations as well.
*
* @param annotatedElement The element to search.
* @param annotationType The annotation type class.
* @param <A> Annotation type to search for.
* @return
*/
@SuppressWarnings("unchecked")
default <A extends Annotation> A findAnnotation(AnnotatedElement annotatedElement, Class<A> annotationType) {
Annotation[] anns = annotatedElement.getDeclaredAnnotations();
for (Annotation ann : anns) {
if (ann.annotationType() == annotationType) {
return (A) ann;
}
}
return null;
}
AnnotationFinder.java 文件源码
java
阅读 41
收藏 0
点赞 0
评论 0
项目:micrometer
作者:
评论列表
文章目录