Java Reflection Annotation getAnnotationDefault(Class annotationClass, String element)

Here you can find the source of getAnnotationDefault(Class annotationClass, String element)

Description

get Annotation Default

License

Apache License

Declaration

@SuppressWarnings("unchecked")
    public static <T> T getAnnotationDefault(Class<? extends Annotation> annotationClass, String element) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T getAnnotationDefault(Class<? extends Annotation> annotationClass, String element) {
        Method method = null;//from  w  w w.  j a  va  2 s. c om
        try {
            method = annotationClass.getMethod(element, (Class[]) null);
        } catch (NoSuchMethodException e) {
            return null;
        }
        return ((T) method.getDefaultValue());
    }
}

Related

  1. getAnnotationClass(Annotation annotation)
  2. getAnnotationClass(Class clazz, Class annotation)
  3. getAnnotationClass(Class entityClass, Class annotationClass)
  4. getAnnotationClass(String name)
  5. getAnnotationDeep(Annotation from, Class toFind)
  6. getAnnotationDefaultMap(Class annotationClass)
  7. getAnnotationElementValue(AnnotatedElement annotatedElement, String annotationClassName, String annotationElementName, Class annotationElementType)
  8. getAnnotationField(Annotation annotation, String field)
  9. getAnnotationFields(Class claz, Class annotationType)