ExpediaGroup/bull

Copy on existing destination

ivanocortesini opened this issue · 6 comments

It would be useful to add the possibility to copy "source" bean properties to an existing destination bean instance like:
beanUtils.getTransformer().transform(fromBean, toBean);

This can improve flexibility:

  • I can use transformer into my bean constructor
  • I can use properties compositing from multiple sources

sounds good but, what is the expected behaviour for the already valorized properties? should the transformer override them? Please, let us know

For sure override them by default. Obviously an "appneding" mode can be a useful as an optional feature ;)

Great! added to the backlog

Hi Ivano,
the feature has been implemented and available from version 1.2.1 (in case you use java 11) or 1.1.7 (in case you use java 8), now is possible to perform the copy on an existing object instance.
For the time being it overrides all the existing values, however, we are working on the possibility to define a set of fields for which the copy has to be skipped, you can follow its status on the issue: #38.
Thanks for contributing in the library improval

Perfect... thank you Fabio

Hi @ivanocortesini, I’m pleased to inform you that the “transformation skip”, on a given set of fields has been implemented, you can find it since version 1.2.4 (if you are using java 11) or 1.1.9 (if you are using java 8 or above).
If you want to know more about this library and its features don’t miss the occasion to join to the dedicated meetup tha will take place on the next 3rd April: https://www.meetup.com/it-IT/Rome-Software-Discussion/events/259532416.
Have a nice day