mapstruct / mapstruct-examples

Examples for using MapStruct
Other
1.28k stars 512 forks source link

Protobuf example #25

Closed eiswind closed 7 years ago

eiswind commented 7 years ago

Null values don't work, as this is not supported in the Builder.

filiphr commented 7 years ago

You can use @Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS). With this the source properrties are always checked and assigned if they are not null.

eiswind commented 7 years ago

Thx. I added the NullValueCheckStrategy. Null values now map to the protobuf defaults. I added the testcase to illustrate the behaviour.

sjaakd commented 7 years ago

See also #14

eiswind commented 7 years ago

I just pushed the changes. Thx for the feedback.

filiphr commented 7 years ago

@eiswind Thanks a lot for the example. I think that it is a really nice addition.

Regarding my https://github.com/mapstruct/mapstruct-examples/pull/25#discussion_r115608662. If you think that it is worth it and it is OK for you, I can add that to your PR, or create a new one, that will do that.

Additionally you had some questions in one of the issues, about not needing to use permissionsList. Do you think that it would be better if you didn't need to write @Mapping(source = "permissions", target = "permissionsList")?

Finally, will it be OK for you if I squash all the commits into one before merging, or you would prefer to have them as is merged into the examples?

eiswind commented 7 years ago

Feel free to make your changes as you prefer!

filiphr commented 7 years ago

Thanks for the PR @eiswind, sorry for taking so long to merge it.