Support reuse of template method arguments
timtebeek opened this issue · comments
Tim te Beek commented
What problem are you trying to solve?
Template method arguments can only be used once in the after template.
Even relatively simple replacements such as this one currently fail.
@AfterTemplate
boolean notNullNotBlank(String s) {
return s != null && !s.isEmpty();
}
Describe the solution you'd like
Template arguments can reliably be used twice in after template and the resulting recipe.
A number of options have been proposed such as:
- adding the argument twice in the parameters passed into
JavaTemplate.apply
, which can't then support arguments that can have side effects - adding named or numbered parameters to the argument handling in
JavaTemplate
as per @knutwannheden