7


I am trying to use Dozer Java API to map two java classes using a custom converter. Is there a way I can configure class-level custom converters in Java? Right now I have to add the configuration in XML:

<configuration>
    <custom-converters>
        <converter type="com.abc.A2BConverter" >
            <class-a>com.abc.ClassA</class-a>
            <class-b>com.abc.ClassB</class-b>
      </converter>
    </custom-converters>     
</configuration>`

Any help is appreciated!

dchen
  • 105
  • 1
  • 5
  • Maybe using the addMapping() method from DozerBeanMapper (http://dozer.sourceforge.net/apidocs/org/dozer/DozerBeanMapper.html) – ndeverge Apr 05 '12 at 19:19
  • Thank you for your reply, nico_ekito. However I haven't found a way to configure class/type level custom converter using the addMapping() method. The customConverter interface does not exist in TypeMappingBuilder or DozerBuilder.MappingBuilder; it is in FieldMappingBuilder. – dchen Apr 06 '12 at 14:43

1 Answers1

8

The Dozer documentation says:

In fact some parts of the configuration (e.g. global configuration block) are only possible to express in Xml format. (Link)

As far as I know class-level custom converters have to be defined in this global configuration block.

So: No, you cannot define them via the Java API.

Sebi
  • 2,534
  • 2
  • 26
  • 28