Consider the following xml dozer bean mapping below:
<mapping map-null="false" map-empty-string="false">
<class-a>com.example.howtodoinjava.dozer.models.Student</class-a>
<class-b>com.example.howtodoinjava.dozer.models.StudentVO</class-b>
<field>
<a>batch</a>
<b>batchName</b>
</field>
<field>
<a>address</a>
<b>homeAddress</b>
</field>
</mapping>
</mappings>
In the above dozer xml mapping, how to avoid map batch to batchName when batch is blank (" ")?
The Dozer documentation is your friend: https://dozermapper.github.io/gitbook/documentation/xmlConfiguration.html
Add trim-strings="true"
to the mapping.
During the mapping of the field, String.trim() will be called on the source field value to "convert" it to the destination. This in combination with the skip empty strings already in the mapping perform as desired.