Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MapStruct 1.3.0.Final. don't ignore non-getter-setter methods

Tags:

mapstruct

I use Mapstruct and JOOQ for mapping between record-class and POJO. Today I tried to switch from Mapstruct 1.2.0.Final to 1.3.0.Final. But I get compilation errors like this - Unmapped target properties: "value1, value2, value3, value4".

JOOQ generate record-class with usual setters/getters and some public non-static methods with a name like valueN. valueN methods generates for each setter/getter.

With Mapstruct 1.2.0.Final it works perfectly fine. ValueN methods ignored in generated mappers. Generated mappers use only getters-setters. I didn't set ignore for ValueN explicitly.

How I can fix this behavior in Mapstruct 1.3.0.Final gracefully? How to configure Mapstruct for using only getters-setters?

Now I see two options:

Option 1. Use @Mapping(target = "value1", ignore = true) for all valueN methods. Can I use some regexp pattern in target prop for ignore all valueN methods in single @Mapping?

Option 2. Write my own AccessorNamingStrategy

Should I just choose one of the options above or Mapstruct has any config options for returning 1.2.0 behavior maybe?

like image 453
jmorozov Avatar asked Feb 15 '26 02:02

jmorozov


1 Answers

In 1.3.0.Final in order to disable the fluent accessors you would have to go with option 1 or option 2 unfortunately.

If you go with option 2 then you can extend from DefaultAccessorNamingStrategy and then for isFluentSetter return false.

like image 157
Filip Avatar answered Feb 21 '26 14:02

Filip



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!