Saturday, 26 December 2020

Android Annotation Processor: Invoke annotated method with a condition

I'm quite new to building a custom annotation processor,
I've followed some tutorials & guides over here on SO too but been stuck on adding a condition for the annotated method.

The problem:
I have a custom annotation directed only for methods,
say, @RUN(isDebug: Boolean) & the method would be:

@RUN(isDebug = true)
private fun runInDebugOnly() {
    ....
}

@RUN(isDebug = false)
private fun runInReleaseOnly() {
    ....
}

So in my Annotation Processor,
is it possible to execute these functions with a condition?
I know the concept of generating a custom class & methods inside it,
But how to exactly intercept the method & use the generated method instead.

Any guidance would be appreciated.



from Android Annotation Processor: Invoke annotated method with a condition

No comments:

Post a Comment