get List Of Class Level Annotation From Class - Java java.lang.annotation

Java examples for java.lang.annotation:Class Annotation

Description

get List Of Class Level Annotation From Class

Demo Code


//package com.java2s;
import java.lang.annotation.Annotation;

import java.util.ArrayList;

import java.util.List;
import java.util.Collections;

public class Main {


    public static List getListOfClassLevelAnnotationFromClass(
            Class annotationClass) {
        List l = new ArrayList();
        Annotation[] classes = annotationClass.getDeclaredAnnotations();
        if (classes.length > 0) {
            Collections.addAll(l, classes);
        }/*from  w  w w.  j a  v a2  s .co m*/
        return l;
    }
}

Related Tutorials