com.silentgo.core.aop.MethodParam Maven / Gradle / Ivy
package com.silentgo.core.aop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;
/**
* Project : silentgo
* com.silentgo.core
*
* @author teddyzhu
*
* Created by teddyzhu on 16/7/27.
*/
public class MethodParam {
public static final Logger LOGGER = LoggerFactory.getLogger(MethodParam.class);
private Class> type;
private String name;
private List> anTypes;
private List annotations;
public Class> getType() {
return type;
}
public String getName() {
return name;
}
public MethodParam(Class> type, String name, List annotations) {
this.type = type;
this.name = name;
this.annotations = annotations;
anTypes = new ArrayList<>();
annotations.forEach(annotation -> anTypes.add(annotation.annotationType()));
}
public boolean existAnnotation(Class extends Annotation> clz) {
return anTypes.contains(clz);
}
public T getAnnotation(Class tClass) {
for (Annotation annotation : annotations) {
if (annotation.annotationType().equals(tClass)) {
return (T) annotation;
}
}
return null;
}
public List getAnnotations() {
return annotations;
}
}