Here you can find the source of getMethodAnnotation(final Method method, final Class
Parameter | Description |
---|---|
method | Method |
annotationType | Class |
public static <T extends Annotation> T getMethodAnnotation(final Method method, final Class<T> annotationType)
//package com.java2s; //License from project: Open Source License import java.lang.annotation.Annotation; import java.lang.reflect.Method; public class Main { /**// w w w .j a v a 2 s. co m * Gets the Annotation for the method, null if does not exists. * @param method Method * @param annotationType Class * @return Annotation */ public static <T extends Annotation> T getMethodAnnotation(final Method method, final Class<T> annotationType) { final Annotation[] annotations = method.getDeclaredAnnotations(); for (Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return (T) annotation; } } return null; } }