Search code examples
javadozer

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


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?


Solution

  • 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.