atos1990 / orika

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

Exclude FieldMap in one direction #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to suppress a mapping of a field (no primitive type) in only one 
direction (MappingDirection.A_TO_B should be excluded)

My source code for this is:

ClassMapBuilder.map( A.class, B.class ).fieldMap( "anyField" 
).aToB().exclude().add();

The result is no mapping in both directions.

Another try is to explicitly add the mapping only for direction B_TO_A.

ClassMapBuilder.map( A.class, B.class ).fieldMap( "anyField" ).bToA().add();

This is working.

I'm using Orika 1.1.7

Best regards
Tom

Original issue reported on code.google.com by insidegr...@gmail.com on 2 Jul 2012 at 3:57

GoogleCodeExporter commented 9 years ago
In fact, exclude is used to exclude mapping in both direction.
use aToB or bToA instead.

Original comment by elaat...@gmail.com on 3 Jul 2012 at 2:20

GoogleCodeExporter commented 9 years ago
OK ... but it would be logical. I can add a FielMap in one direction ... so why 
not excluding a FieldMap for one direction.

Both lines of code should do the same:

ClassMapBuilder.map( A.class, B.class ).fieldMap( "anyField" ).aToB().exclude();
ClassMapBuilder.map( A.class, B.class ).fieldMap( "anyField" ).bToA().add();

Anyway ... it works with the second line.

Original comment by insidegr...@gmail.com on 9 Jul 2012 at 10:56

GoogleCodeExporter commented 9 years ago
In the FieldMapBuilder exclude is just a flag (boolean) 
Do you have any suggestions/critics  for documentation

Original comment by elaat...@gmail.com on 9 Jul 2012 at 12:54

GoogleCodeExporter commented 9 years ago

Original comment by elaat...@gmail.com on 9 Jul 2012 at 1:21

GoogleCodeExporter commented 9 years ago
Documentation for this feature would be good. (It's totally missing)

Btw ... cool API ... good job

Thx
Tom

Original comment by insidegr...@gmail.com on 11 Jul 2012 at 8:54