Template that compares field type
Answered
Hi.
In the template, how could I create a @if statement that checks the $field type against List, Collections and Set?
I am trying to adapt the current generate getter template to handle collections in a differente way.
Instead of:
public List<X> getListOfX() {
return listOfX;
}
I would like to generate:
public List<X> getListOfX() {
return Collections.unmodifiableList(listOfX);
}
I could not find a documentation about this.
Best regards,
Daniel Felix Ferber
Please sign in to leave a comment.
Hello, unfortunately there is no possibility to make this check with velocity template. You may use the Assignment or return of field with mutable type inspection (Java | Encapsulation | Assignment or return of field with mutable type).
Fix all intention may be applied for several getters: