Mega Code Archive

 
Categories / Java / Reflection
 

Get default annotation value

import java.lang.annotation.Annotation; import java.lang.reflect.Method; public class Util{   @SuppressWarnings("unchecked")   public static<T> T getAnnotationDefault(Class<? extends Annotation> annotationClass,String element) throws Exception {     Method method = annotationClass.getMethod(element,(Class[])null);     return((T)method.getDefaultValue());   } }