📅  最后修改于: 2022-03-11 14:52:23.532000             🧑  作者: Mango
public void configure(ModelMapper modelMapper) {
modelMapper.typeMap(QuestionDto.class, AbstractItem.class)
.setConverter(converterWithDestinationSupplier(Question::new));
modelMapper.typeMap(CriteriaDto.class, AbstractItem.class)
.setConverter(converterWithDestinationSupplier(Criteria::new));
}
private Converter converterWithDestinationSupplier(Supplier extends D> supplier ) {
return ctx -> ctx.getMappingEngine().map(ctx.create(ctx.getSource(), supplier.get()));
}