【发布时间】:2016-02-08 21:31:44
【问题描述】:
我在上面的方法上有这个注解,它是在一个由 Spring (BeanNameAutoProxy) 代理的 bean 上。
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CustomAnnotation{
public boolean enabled() default true;
}
CustomAnnotation.class.getClass() 给我interface mypackage.CustomAnnotation
methodInvocation.getMethod().getAnnotations()[0].getClass() 给我@mypackage.CustomAnnotation
所以 equals 在同一注解的两个 getClass() 方法之间返回 false。
我有List<Class> annotationClassList,我添加到列表CustomAnnotation.getClass();
我想检查methodInvocation.getMethod().getAnnotations()[0].getClass() 是否在列表中。
最好的检查方法是什么?
【问题讨论】:
标签: java spring annotations