我有以下两个课程
class A {
class InnerA {
private String field;
// getters/setters
}
private Collection<InnerA> collection;
// getters/setters
}
class B {
private String field;
// getters/setters
}
是否可以将 A 映射到 B 的集合(A.collection.field 应该映射到 B.field 的集合)?
我尝试使用自定义转换器,但我只需要管理 java.lang.VerifyError:
mapperFactory.getConverterFactory().registerConverter(new CustomConverter<A, Collection<B>>() {
@Override
public Collection<B> convert(
A arg0, Type<? extends Collection<B>> arg1) {
Collection<B> result = new ArrayList<B>();
Iterator<Item> it = arg0.getCollection().iterator();
while(it.hasNext()){
it.next();
result.add(new B());
}
return result;
}
});
结果是:
java.lang.VerifyError: Inconsistent args count operand in invokeinterface in method ma.glasnost.orika.generated.Orika_ArrayList_A_Mapper845657274.mapAtoB(Ljava/lang/Object;Ljava/lang/Object;Lma/glasnost/orika/MappingContext;)V at offset 74
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.newInstance0(Class.java:343)
at java.lang.Class.newInstance(Class.java:325)