1

I'm trying to recreate a class using JavaPoet. What's the best way to do this?

Basically, I want to generate another class with one method with appended statements.

kaneda
  • 5,981
  • 8
  • 48
  • 73

1 Answers1

-1

JavaPoet can’t easily modify existing code. This is potentially quite difficult because features like import resolution rely on parsing types properly.

You might be able to cheat by emitting a new file and then using a StringBuilder to manually concatenate imports and members. You might need some regexes.

Jesse Wilson
  • 39,078
  • 8
  • 121
  • 128