0

I'm having something like this

@Value(name="values1", values = { R.string.first, R.string.second, R.string.third })

and it's variation

@Value(name="values2", values = { R.integer.first, R.integer.second, R.integer.third })

R.integer.* and R.string.* are just int constants declared in corresponding classes.

So, during annotation processing I somehow need to get full names (e.g. "R.integer.first") instead of getting actual int value of R.integer.first.

For now I only able to read values:

Value debug = e.getAnnotation(Value.class);
String name= debug.name();
int[] values = debug.values();
Ivan
  • 1,446
  • 2
  • 11
  • 25

1 Answers1

0

Seems I found an answer, so due my observation you can only access final values as likely compiler replaces constants with actual values on earlier stages of compilation.

And mechanism of accessing data in annotation is following:

for (AnnotationMirror mirror : e.getAnnotationMirrors()) {
    for (ExecutableElement el : mirror.getElementValues().keySet()) {
        info("Element:" + el + " Value:" + elementValues.get(el));
    }
}

Where e is Element obtained via annotation processor

Ivan
  • 1,446
  • 2
  • 11
  • 25