I am currently replacing all my standard POJOs to use Lombok for all template code. I find that I am storing getters for lists because I want to return an empty list if the list has not been initialized. That is, I do not want getter to return null. If some kind of Lombok magic that I don’t know about can help me avoid this?
Sample Generated Code
private List<Object> list; public Object getList(){ return list; }
Instead, I would like to:
private List<Object> list; public Object getList(){ if (list == null) { return new ArrayList(); } return list; }
source share