atos1990 / orika

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

'Strict' mode #54

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to be able to have a mode where Orika does not generate 
mappers for undeclared pairs but throws an exception that such a mapper is not 
defined.

There are a number of benefits to using this approach when creating mappings 
for structures that are drastically different from each other (have little to 
no corresponding fields). In this case mappers that are generated automatically 
using the byDefault() method are not going to be very useful and having them 
pop up each time you forget to define a mapping can be daunting since they can 
be hard to catch. 

Having a mode that forces the developer to define each mapping manually has a 
few benefits:
* Easier to write unit tests and find bugs in your code - the framework spits 
out an exception telling you to define a mapping.
* The framework can perform some stricter validation during initialization - 
each Object-Object mapping in a mapper can be checked for undefined mappings 
because no new mappers can be introduced at runtime. 

What do you guys think? 

Original issue reported on code.google.com by lighteater on 18 Sep 2012 at 2:44

GoogleCodeExporter commented 9 years ago
We already have a configuration parameter which turns default mapping on/off -- 
have you tried this?

new DefaultMapperFactory.Builder().useAutoMapping(false).build();

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

GoogleCodeExporter commented 9 years ago
Nope, you should mention that somewhere in the GettingStarted article :) Thanks.

Original comment by lighteater on 19 Sep 2012 at 8:39

GoogleCodeExporter commented 9 years ago
Will do.

Original comment by matt.deb...@gmail.com on 19 Sep 2012 at 8:30

GoogleCodeExporter commented 9 years ago
Now added to the GettingStarted wiki

Original comment by matt.deb...@gmail.com on 5 Oct 2012 at 3:13