Check if an AccessibleObject has Annotation - Java java.lang.annotation

Java examples for java.lang.annotation:Annotation Attribute

Description

Check if an AccessibleObject has Annotation

Demo Code


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

public class Main {
    public static boolean hasAnnotation(AccessibleObject member,
            Class<? extends Annotation> annotationClass) {
        Annotation annotation = member.getAnnotation(annotationClass);
        return annotation != null;
    }/*from   w  w  w.  ja  v a 2s . com*/
}

Related Tutorials