com.github.mengweijin.quickboot.framework.util.AspectUtils Maven / Gradle / Ivy
package com.github.mengweijin.quickboot.framework.util;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.reflect.MethodSignature;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
/**
* @author Meng Wei Jin
* @description
**/
public class AspectUtils {
/**
* 方法上是否存在注解,如果存在就获取
*/
public static T getMethodAnnotation(JoinPoint joinPoint, Class annotationClass) {
Signature signature = joinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method method = methodSignature.getMethod();
if (method != null) {
return method.getAnnotation(annotationClass);
}
return null;
}
}