推土机将列表中对象的属性映射到带有提示的另一个列表

时间:2013-11-07 21:46:38

标签: dozer mapper

我有以下的映射方案

Class Contact {

List<SimpleCode> marketSectorList;

}

Class SimpleCode {

 protected String code;
 protected String label;

}

Class ContactTarget {
  List<String> marketSectors;
}

The following map is not working
<mapping> 
    <class-a>Contact</class-a>
    <class-b>ContactTarget</class-b>  

<field>
        <a>marketSectorList</a>
        <b>marketSectors</b>
        <b-hint>java.lang.String</b-hint> 
</field> 

映射无效。请注意,我无法更改类,我想通过使用提示而不是自定义映射器来解决

1 个答案:

答案 0 :(得分:1)

您可以尝试创建从SimpleCode到java.lang.String的映射,以便dozer知道如何映射这些对象。类似的东西:

<mapping> 
    <class-a>SimpleCode</class-a>
    <class-b>java.lang.String</class-b>  

    <field>
        <a>code</a>
        <b>this</b>
     </field>
</mapping>

我希望它有所帮助。

相关问题