Initialize list if list is null with lombok getter?

You can achieve this by declaring and initializing the fields. The initialization will be done when the enclosing object is initialized.

private List<Object> list = new ArrayList();

Lomboks @Getter annotation provides an attribute lazy which allows lazy initialization.

 @Getter(lazy=true) private final double[] cached = expensiveInitMethod();

Documentation

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)