Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java getter/setter generation with Lombok for code with annotations

I use Project Lombok to automatically generate getter and setter methods for all fields of a Java class.

When a field is annotated with e.g. @XmlTransient, the annotation is not propagated to the generated getter/setter methods, thus in the resulting code it does not show any effect. Is there a way to use automatic getter/setter generation in conjunction with further annotations?

like image 483
rmv Avatar asked Sep 08 '10 08:09

rmv


Video Answer


1 Answers

I don't think propagating annotations to getter/setter methods would work in the general case. For example do you know what would happen if both the field and the bean properties were annotated with @XmlElement? For JAXB annotations I would suggest using @XmlAccessorType(XmlAccessType.FIELD) on the field.

like image 121
Jörn Horstmann Avatar answered Nov 02 '22 06:11

Jörn Horstmann