Java Reflection Annotation getAnnotations(Annotation[][] annotations)

Here you can find the source of getAnnotations(Annotation[][] annotations)

Description

get Annotations

License

Apache License

Declaration

static List<Annotation> getAnnotations(Annotation[][] annotations) 

Method Source Code


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

import java.lang.annotation.Annotation;
import java.util.LinkedList;
import java.util.List;

public class Main {
    static List<Annotation> getAnnotations(Annotation[][] annotations) {
        final List<Annotation> result = new LinkedList<>();

        for (int i = 0; i < annotations.length; i++) {

            if (annotations[i].length > 1) {
                throw new RuntimeException("you can only assign one annotation");
            }//from   w w w  .  j  av  a  2  s . c o m
            Annotation annotation = annotations[i][0];

            result.add(annotation);
        }
        return result;
    }
}

Related

  1. getAnnotationOuterIndecies(Class annotationClass, Annotation[][] annotations)
  2. getAnnotationPropertyValue(Annotation a, String annotationPropertyName)
  3. getAnnotationRecursive(Class cls, Class annotationClass)
  4. getAnnotations(AnnotatedElement ae, Class annotationType)
  5. getAnnotations(AnnotatedElement annotated)
  6. getAnnotations(Class cls)
  7. getAnnotations(Class annotationClass, Annotation[] annotations)
  8. getAnnotations(Class c, Class annotationClass)
  9. getAnnotations(Class annotation, Collection annotations)