2

私は次のようなオブジェクトを持っています

public class Foo{

    private List<List<AnotherFoo>> anotherFooList;
}

そして、私は次のようなDTOオブジェクトを持っています

public class FooDTO{

    private List<List<AnotherFooDTO>> anotherFooList;
}

通常のドーザーコンバーターでは例外があります。これは、ここで述べられているようなドーザーの問題であるためです: 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)
    ...

誰でもこれを解決する方法の手がかりを持っていますか?

4

0 に答える 0