Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to include or exclude attributes while mapping in orika mapper?

Tags:

orika

I am using Orika Mapper. I want to know that can I include or exclude the attributes while mapping using Orika Mapper. If it is possible then how to do the same?

like image 629
Sanjog Yadav Avatar asked Mar 15 '23 22:03

Sanjog Yadav


1 Answers

You can include attributes simply by defining the mapping. Have a look at the User Guide.

You can use byDefault() to automatically map fields with the same names, explicitly define two-way mappings using field("fieldA", "fieldB") or one-way mappings using fieldAtoB("fieldA", "fieldB") and fieldBtoA("fieldB", "fieldA").

If you want to explicitly exclude a field from mapping (eg. when using byDefault()), you can use exclude("field"). You can chain .exclude("field1").exclude("field2").exclude("field3") multiple times to exclude multiple fields.

like image 50
Adam Michalik Avatar answered Jun 05 '23 09:06

Adam Michalik