javaannotationsjavapoet

Is it possible to just add method to class with Java Poet?


I am wondering if is it possible to add method to class without having to rewrite whole class again using Java Poet?

Thanks


Solution

  • JavaPoet emits source code, nothing else. It can't consume the source code of an existing class.

    You could emit a method with it and insert it into the body of a class some other way, but that's as good as it gets.