我有像
这样的对象public class Foo{
private List<List<AnotherFoo>> anotherFooList;
}
我有像
这样的DTO对象public class FooDTO{
private List<List<AnotherFooDTO>> anotherFooList;
}
在常规推土机转换器上我有一个例外,因为这是推土机问题,如下所述:Map list of lists with Dozer
所以我尝试为这个字段做了一个自定义转换器抛出这样的bean
<bean id="customConverterBean" class="com.bla.CustomConverterBean">
<constructor-arg value="[L[Lcom.bla.AnotherFoo;;" />
<constructor-arg value="[L[Lcom.bla.AnotherFooDTO;;" />
</bean>
<mapping>
<class-a>com.bla.Foo</class-a>
<class-b>com.bla.FooDTO</class-b>
<field custom-converter-id="customConverterBean"><a>anotherFooList</a><b>anotherFooList</b></field>
</mapping>
和我的班级:
public class CustomConverterBean extends DozerConverter<List<List<AnotherFoo>>, List<List<AnotherFooDTO>>> {
public CustomConverterBean(Class<List<List<AnotherFoo>>> prototypeA, Class<List<List<AnotherFooDTO>>> prototypeB) {
super(prototypeA, prototypeB);
}
@Override
public List<List<TrSectionDTO>> convertTo(List<List<AnotherFoo>> source, List<List<AnotherFooDTO>> destination) {
if(source==null){
return null;
}
return null;
}
@Override
public List<List<AnotherFoo>> convertFrom(List<List<AnotherFooDTO>> source, List<List<AnotherFoo>> destination) {
return null;
}
}
但是当试图转换时我有一个例外:
org.dozer.MappingException: Destination Type (java.util.List) is not accepted by this Custom Converter (com.bla.CustomConverterBean)!
at org.dozer.DozerConverter.convert(DozerConverter.java:64)
...
任何人都知道如何解决这个问题?