I've been browsing the apt "tutorial" and the com.sun.mirror package and finally figured out how to go through my annotations in my source code. My only question is...how do I generate a new source file with the adjustments caused by the annotations?
For example, I have an interface Inter with one method: method(). I make an annotation @CallFromMethod to mark methods in a class that should be called from that class' method() method. I make the appropriate AnnotationProcessor and AnnotationProcessorFactory, and I go through all the @CallFromMethod annotations in a source file. How do I change this:
1 2 3 4 5 6 7
| public class SourceTest {
@CallFromMethod public callMe() { ... } } |
into this:
1 2 3 4 5 6 7 8 9 10
| public class SourceTest implements Inter {
public callMe() { ... }
public void method() { callMe(); } } |
using the apt? I know the example is stupid, but bear with me and please try to help me out.
Thanks in advance!