Check if Annotation array contains an Annotation - Java java.lang.annotation

Java examples for java.lang.annotation:Annotation Attribute

Description

Check if Annotation array contains an Annotation

Demo Code


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

public class Main {
    public static boolean contains(Annotation[] array,
            Class<? extends Annotation> type) {
        for (Annotation annotation : array) {
            if (annotation.annotationType().equals(type)) {
                return true;
            }//  www .ja  va 2  s.c  om
        }
        return false;
    }
}

Related Tutorials