AArhin / orika

Automatically exported from code.google.com/p/orika
0 stars 0 forks source link

Throw exception if destination properties are untouched after mapping #51

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
It would be very nice if a flag could be toggled to throw an exception if a 
destination property was not mapped during the mapping process. This would 
allow for catching a lot of issues where not all fields are being properly 
mapped at runtime.

Original issue reported on code.google.com by dain.kap...@gmail.com on 12 Sep 2012 at 4:33

GoogleCodeExporter commented 8 years ago
What if we updated the debug logging to include information about the 
properties that were skipped for each type during mapper generation?

Original comment by matt.deb...@gmail.com on 13 Sep 2012 at 12:49

GoogleCodeExporter commented 8 years ago
That would definitely help, though ideally, there would be a feature similar to 
ModelMapper's modelMapper.validate(), which throws an exception if any of the 
registered mappings do not properly evaluate. Would this be possible?

Original comment by dain.kap...@gmail.com on 13 Sep 2012 at 2:58

GoogleCodeExporter commented 8 years ago
It's definitely worth looking at. 
Could you give a little more detail ?: 
By "not properly evaluate" do you mean that you explicitly registered some 
mapping and it was not used?
Or you explicitly registered some fields on a particular mapping and they were 
ignored?
Or you let Orika auto-map, and it "missed" matching up some fields?
Or something else?

Original comment by matt.deb...@gmail.com on 13 Sep 2012 at 8:46

GoogleCodeExporter commented 8 years ago
>> By "not properly evaluate" do you mean that you explicitly registered some 
mapping and it was not used?
>> Or you explicitly registered some fields on a particular mapping and they 
were ignored?
>> Or you let Orika auto-map, and it "missed" matching up some fields?
>> Or something else?

All of the above? Essentially, evaluate a source -> destination mapping, and if 
property in the destination object wasn't mapped, for any reason, throw an 
error. This operates on the assumption that destination objects are just DTOs 
where all fields are meaningful (the field wouldn't be there if you didn't want 
it filled). Perhaps more sophisticated rules could be devised, but having a 
function that I could call that would evaluate all _registered_ mappings would 
be fantastic. (mappings that happen dynamically do not need to be included.)

What do you think?

Original comment by dain.kap...@gmail.com on 30 Sep 2012 at 1:28