ModelMapper Abstract Class
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 <S, D> Converter<S, D> converterWithDestinationSupplier(Supplier<? extends D> supplier ) {
return ctx -> ctx.getMappingEngine().map(ctx.create(ctx.getSource(), supplier.get()));
}
Pleasant Pigeon