변수 매핑을 사용하면 소스 필드의 값을 사용하는 대신 Dozer 구성 내의 변수 정의 값을 target 필드에 매핑할 수 있습니다. 이는 다른 매핑 프레임워크의 연속 매핑과 같습니다. 여기서 대상 필드에 리터럴 값을 할당할 수 있습니다. 변수 매핑을 사용하려면 매핑 구성 내에서 변수를 정의한 다음 VariableMapper 클래스에서 선택한 대상 필드에 매핑하면 됩니다.
<mappings xmlns="http://dozermapper.github.io/schema/bean-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dozermapper.github.io/schema/bean-mapping http://dozermapper.github.io/schema/bean-mapping.xsd">
<configuration>
<variables>
<variable name="CUST_ID">ACME-SALES</variable>
</variables>
</configuration>
<mapping>
<class-a>org.apache.camel.component.dozer.VariableMapper</class-a>
<class-b>org.example.Order</class-b>
<field custom-converter-id="_variableMapping" custom-converter-param="${CUST_ID}">
<a>literal</a>
<b>custId</b>
</field>
</mapping>
</mappings>
<mappings xmlns="http://dozermapper.github.io/schema/bean-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dozermapper.github.io/schema/bean-mapping http://dozermapper.github.io/schema/bean-mapping.xsd">
<configuration>
<variables>
<variable name="CUST_ID">ACME-SALES</variable>
</variables>
</configuration>
<mapping>
<class-a>org.apache.camel.component.dozer.VariableMapper</class-a>
<class-b>org.example.Order</class-b>
<field custom-converter-id="_variableMapping" custom-converter-param="${CUST_ID}">
<a>literal</a>
<b>custId</b>
</field>
</mapping>
</mappings>
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow