Java Reflection Annotation getAnnotationClass(Annotation a)

Here you can find the source of getAnnotationClass(Annotation a)

Description

get Annotation Class

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
    private static Class<? extends Annotation> getAnnotationClass(Annotation a) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.annotation.Annotation;

public class Main {
    @SuppressWarnings("unchecked")
    private static Class<? extends Annotation> getAnnotationClass(Annotation a) {
        Class<?>[] interfaces = a.getClass().getInterfaces();
        assert interfaces.length == 1 : "Customize annotations with multiple interfaces are not supported: "
                + a.getClass();/*from w w w.jav  a  2 s  . c om*/
        return (Class<? extends Annotation>) interfaces[0];

    }
}

Related

  1. getAnnotationAttributes(Annotation annotation)
  2. getAnnotationAttributes(final Annotation annotation)
  3. getAnnotationAttributeValue(final Annotation annotation, final String attributeName)
  4. getAnnotationByType(AnnotatedElement element, Class annotationType)
  5. getAnnotationByType(List annotations, Class annotationType)
  6. getAnnotationClass(Annotation annotation)
  7. getAnnotationClass(Class clazz, Class annotation)
  8. getAnnotationClass(Class entityClass, Class annotationClass)
  9. getAnnotationClass(String name)