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.
Hardcore gay porn starring the best of the genre https://hardcoregaytubeporn.com
Please sign in to leave a comment.
Hello, in case you already have the getter generated in the following way in class:
public List<Clazz.X> getListOfX() {return listOfX;
}
you may use the fix suggested by the inspection Java | Encapsulation | Assignment or return of field with mutable type, that will transform the code to:
public List<Clazz.X> getListOfX() {return Collections.unmodifiableList(listOfX);
}