I am trying to migrate a project that use dozer
to orika
.
In dozer, it's a common practice to have something like that :
<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns="http://dozer.sourceforge.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dozer.sourceforge.net
http://dozer.sourceforge.net/schema/beanmapping.xsd">
<mapping map-id="all">
<class-a>com.bnppa.cdj.dto.Source</class-a>
<class-b>com.bnppa.cdj.dto.Destination</class-b>
<field>
<a>id</a>
<b>id</b>
</field>
<field>
<a>someField</a>
<b>someField</b>
</field>
</mapping>
<mapping map-id="small">
<class-a>com.bnppa.cdj.dto.Source</class-a>
<class-b>com.bnppa.cdj.dto.Destination</class-b>
<field>
<a>id</a>
<b>id</b>
</field>
</mapping>
</mappings>
And then use the mapId when converting the object :
Source s = ...
List<String> mappingFiles = new ArrayList<String>();
mappingFiles.add("dozer/dozerMapping.xml");
mapper = new DozerBeanMapper(mappingFiles);
Destination d = mapper.map(mySource, Destination.class, "small");
So my question is : How to configure Orika to have the such mapId things ?
I can't find how to declare a map-id when I define my mappers :
MapperFactory factory = new DefaultMapperFactory.Builder().build();
//Register a mapper
factory.registerClassMap(factory.classMap(Source.class, Destination.class)
.field("id","id")
.field("someField", "someField")
.toClassMap());