在调用某个接口时,能得到该接口上的注解值

在调用某个接口时,能得到该接口上的注解值,把这个值当作参数,传给我的方法中判断

img

请问该怎么 做呢 , 调一个接口传一个值给我,这种

举个例子

@MyAnnotation(value = "class")
public class MyAnnotationTest {
    @Test
    @MyAnnotation(value = "method")
    public void test() throws NoSuchMethodException {
        // 类上
        System.out.println(MyAnnotationTest.class.getAnnotation(MyAnnotation.class).value());
        // 方法上
        System.out.println(MyAnnotationTest.class.getMethod("test").getAnnotation(MyAnnotation.class).value());
    }
}

@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation {
    String value();
}