Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dozer: get first value on a collection mapped to single value in destination

Tags:

java

dozer

I am mapping two DTO objects through Dozer mapper. I am interested in choosing one value from list and map it to a single field in the destination file.

Is it possible to use mapping like this:

<field>
   <a>someList[0]</a>
   <b>someVariable</b>
</field>

It seems that b part can have a list[1].value type of approach, but I cannot get it to work when brackets are on a side. Where am I making it wrong?

like image 586
mico Avatar asked Oct 07 '22 04:10

mico


1 Answers

Actually, you don't need more than suggested

<field>
    <a>someList[0]</a>
    <b>someVariable</b>
</field>

structure to achieve this. I had the problem other where: I did not call the correct map() function for that mapping on my code. I had several mappings and the map() call to this specific one was missing.

like image 127
mico Avatar answered Oct 12 '22 12:10

mico