find Annotation from Annotation array - Java java.lang.annotation

Java examples for java.lang.annotation:Annotation Attribute

Description

find Annotation from Annotation array

Demo Code


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

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T find(Annotation[] array, Class<T> type) {
        for (Annotation annotation : array) {
            if (annotation.annotationType().equals(type)) {
                return (T) annotation;
            }/*from   www . j a  va  2s . com*/
        }
        return null;
    }
}

Related Tutorials