I'm trying to learn annotation processors. I'm trying to create a custom annotation that would send a certain object to a certain method. Both of them will be annotated with the same annotation.
For Example:
public void processData(@MyAnnotation("xyz") Object obj) {
// applies certain computations on the obj and then broadcasts the object using Android's Broadcast
}
Now there are 2 methods that have one argument of type Object
. I want my annotaton processor to intercept the Android Broadcast & then call the method that's @MyAnnotation("xyz") annotation only.
@MyAnnotation("xyz")
public void method1(Object obj) {//...
}
@MyAnnotation("abc")
public void method2(Object obj) {//...
}
So in this case, the custom annotation processor will call ONLY method 1.
I'm not really sure if this is even possible, but if it's, How can I acheive this? I don't want code. I want direction and may be a tutorial that can help me achieve this custom annotation on my own.