---
title: "Dozer Sample"
author: "zenius"
date: "2009-04-14T01:07:45Z"
tags: []
slug: "dozer-sample"
draft: false
lastmod: "2009-04-14T01:07:45Z"
id: 366878
url: "https://zenius.iteye.com/blog/366878"
---

Configurable dozer converter:

```java

public class BalanceConverter implements ConfigurableCustomConverter {

    public Object convert(Object destinationFieldValue, Object sourceFieldValue,
            Class destinationClass, Class sourceClass, String param) {

        Balance[] source = (Balance[]) sourceFieldValue;
        //BigDecimal destination = (BigDecimal) destinationFieldValue;
        
        for (Balance balance : source) {
            if (param.equals(balance.getBalanceId())) {
                return balance.getBalance();
            }
        }
        
        return null;
    }
}

```


```xml

      <field custom-converter="customConverters[0]"
           custom-converter-param="CUR">
        <a>balances</a>
        <b>currentBalance</b>
      </field>

```


```xml

<bean id="mapper" class="org.dozer.DozerBeanMapper">
  <property name="mappingFiles">
    <list>
      <value>account-mappint.xml</value>           
    </list>
  </property>
 <property name="customConvertersWithId"> 
      <map> 
             <entry key="balanceConverter">
                  <ref bean="balanceConverter"/>
            </entry>
      </map> 
    </property>   
</bean> 

```