Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaParser AnnotationExpr get parameters

Tags:

java

parsing

I have an AnnotationExpr, how do I get parameters and their values of the annotation (e.g. @UnityBridge(fullClassName = "test") - how do I obtain a value of fullClassName parameter). Does JavaParser support this?

Do I have to accept another visitor? Which one in this case?

like image 481
Taras Leskiv Avatar asked Mar 24 '26 23:03

Taras Leskiv


1 Answers

Late answer, I came into the same problem, just cast the AnnotationExpr to one of following:

MarkerAnnotationExpr (for no parameter),

SingleMemberAnnotationExpr (for single parameter),

NormalAnnotationExpr (for multiple parameters).

You may need instanceof to determine current annotation type.

like image 115
notsyncing Avatar answered Mar 27 '26 13:03

notsyncing