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.

3

1 Answer 1

0

You can get the annotation from the Method

 CustomAnnotation customAnnotation = CustomAnnotationTest.class
         .getDeclaredMethod("annotationTest", String.class)
         .getAnnotation(CustomAnnotation.class);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.