如何以编程方式为推土机设置自定义转换器?以下代码不起作用:
自定义转换器实现:
class ConverterImpl extends DozerConverter<A, B> {
ConverterImpl() {
super(A.class, B.class);
}
@Override
public B convertTo(A source, B destination) {
return destination;
}
@Override
public A convertFrom(B source, A destination) {
return destination;
}
}
测试代码:
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.setCustomConverters(Collections.<CustomConverter>singletonList(new ConverterImpl()));
A a = new A();
B b = mapper.map(a, A.class);
运行上面的代码后,自定义转换器不会被调用。怎么了?