0

currently i am working on custom annotation and i am trying to catch declared annotated method parameter value here is example:

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomAnnotation {

}

public class CustomAnnotationTest {

  @CustomAnnotation
  public void annotationTest(String address){
    System.out.println("address :" + address);
  }
}

here how can i read this annotationTest method parametr value "address" using

@customAnnotation.

thanks.

avadhoot
  • 377
  • 1
  • 3
  • 9

1 Answers1

0

You can get the annotation from the Method

 CustomAnnotation customAnnotation = CustomAnnotationTest.class
         .getDeclaredMethod("annotationTest", String.class)
         .getAnnotation(CustomAnnotation.class);
René Link
  • 48,224
  • 13
  • 108
  • 140