Using @Getter
on a List
field works fine, but on attempting to upgrade to Java 8 I encounter ConcurrentModificationException
s because the getter generated by Lombok does not perform a copy of the field, which is essential should you wish to prevent external modification of the instance's state.
Any ideas how I can get Lombok to copy the Collection
on getters, or am I restricted to writing my own?
From @Getter and @Setter documentation:
You can annotate any field with @Getter and/or @Setter, to let lombok generate the default getter/setter automatically. A default getter simply returns the field, and is named getFoo if the field is called foo (or isFoo if the field's type is boolean). A default setter is named setFoo if the field is called foo, returns void, and takes 1 parameter of the same type as the field. It simply sets the field to this value.
Since you want more functionality then the default getter you'll have to write your own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With