dozer
을 사용하는 프로젝트를 orika
으로 마이그레이션하려고합니다.컨텍스트에 따라 클래스를 다른 클래스에 매핑하도록 Orika를 구성하는 방법은 무엇입니까?
<?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>
를 그리고 객체 변환 할 때의 mapId를 사용하십시오 : 방법을 구성 할 수 :
이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");
그래서 제 질문은이 도저에
, 그것은 그런 일을하는 것이 일반적이다 오리카, 그런 mapId 것들을 가지고 있나?
나는 내 매퍼를 정의 할 때지도-ID를 선언하는 방법을 찾을 수 없습니다 :
MapperFactory factory = new DefaultMapperFactory.Builder().build();
//Register a mapper
factory.registerClassMap(factory.classMap(Source.class, Destination.class)
.field("id","id")
.field("someField", "someField")
.toClassMap());