Skip to content

Is it generally preferred to use JavaTemplate instead of new'ing up elements "manually"? #275

Answered by tkvangorder
aegershman asked this question in Q&A
Discussion options

You must be logged in to vote

While JavaTemplate is fully capable of doing these types of refactoring operations, I guess the answer is "it depends". We did not add any sort of coordinates for modifiers, because it just seemed like you could easily manipulate the modifiers via ListUtils.

As for implements: In a majority of the cases you are simply adding a fully-qualified class name, the one exception to this might be where you need to implement an interface that has type parameters.

While using JavaTemplate is easy (and fast), there is still some overhead because it is pruning an existing AST, inserting the template to create a synthetic compilation unit, compiling that code, and then extracting/merging the generated…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jkschneider
Comment options

Answer selected by timtebeek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants