87.6. 매핑 확장

Dozer 구성 요소는 Dozer 매핑 프레임워크에 대한 여러 확장을 사용자 지정 변환기로 구현합니다.  이러한 변환기는 Dozer 자체에서 직접 지원하지 않는 매핑 함수를 구현합니다.

87.6.1. 변수 매핑

변수 매핑을 사용하면 소스 필드의 값을 사용하는 대신 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>