Java examples for java.lang.annotation:Annotation Attribute
get Interface Annotation
//package com.java2s; import java.lang.annotation.Annotation; import java.lang.reflect.Method; public class Main { public static <T extends Annotation> T getInterfaceAnnotation( Method method, Class<T> annotationClass) { for (Class<?> iface : method.getDeclaringClass().getInterfaces()) { try { Method m = iface.getMethod(method.getName(), method.getParameterTypes()); return m.getAnnotation(annotationClass); } catch (NoSuchMethodException ignore) { }/*from ww w . j av a2 s.c om*/ } return null; } }