Sanjog Yadav
Sanjog Yadav

Reputation: 55

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

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?

Upvotes: 4

Views: 8698

Answers (1)

Adam Michalik
Adam Michalik

Reputation: 9945

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.

Upvotes: 7

Related Questions