Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customised Setter and Getter in Lombok

Lombok @Data annotation will dumbly add setter and getter of fields on the annotated class.

how to add condition based setter in lombok?

public void setName(final String name){
      this.name = StringUtils.trimToEmpty(name);
}

is there any support in lombok like this @Setter(condition = StringUtils.isEmpty)

i have searched in lombok doc's i see no explanation regarding my issue.

like image 496
kavetiraviteja Avatar asked Nov 28 '25 22:11

kavetiraviteja


1 Answers

you can just add another setter, it will override lombok's implenmention

like image 89
Mobility Avatar answered Nov 30 '25 13:11

Mobility



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!