add
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
package com.qiaoba.common.base.utils;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 注解Util
|
||||
*
|
||||
* @author ailanyin
|
||||
* @version 1.0
|
||||
* @since 2023/6/21 9:53
|
||||
*/
|
||||
public class AnnotationUtil extends cn.hutool.core.annotation.AnnotationUtil {
|
||||
|
||||
public static boolean hasAnnotation(String referenceMethod, Class<? extends Annotation> annotation) {
|
||||
// com.qiaoba.common.base.utils.AnnotationUtil.hasAnnotation
|
||||
StringBuilder sb = new StringBuilder(referenceMethod);
|
||||
int index = sb.lastIndexOf(".");
|
||||
// com.qiaoba.common.base.utils.AnnotationUtil
|
||||
String clazzName = sb.substring(0, index);
|
||||
// hasAnnotation
|
||||
String methodName = sb.substring(index + 1, sb.length());
|
||||
Class<?> clazz = ClassUtil.loadClass(clazzName);
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if (methodName.equals(method.getName())) {
|
||||
return hasAnnotation(method, annotation);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user