package es.internna.framework.utils;
import java.lang.annotation.Annotation;
import org.springframework.aop.framework.Advised;
public class ClassUtils
{
public final static Class<?> getTargetClass (Object bean) {
Class clazz = null;
if (bean != null) {
if (Advised.class.isInstance(bean)) {
Advised advised = (Advised) bean;
clazz = advised.getTargetSource().getTargetClass();
} else clazz = bean.getClass();
}
return clazz;
}
public final static <A extends Annotation> A getAnnotation(Class<A> annotationClass, Object bean) {
A annotation = null;
if ((annotationClass != null) & (bean != null)) {
Class<?> clazz = getTargetClass(bean);
if (clazz.isAnnotationPresent(annotationClass)) annotation = clazz.getAnnotation(annotationClass);
}
return annotation;
}
}