1public void configure(ModelMapper modelMapper) {
2 modelMapper.typeMap(QuestionDto.class, AbstractItem.class)
3 .setConverter(converterWithDestinationSupplier(Question::new));
4 modelMapper.typeMap(CriteriaDto.class, AbstractItem.class)
5 .setConverter(converterWithDestinationSupplier(Criteria::new));
6}
7
8private <S, D> Converter<S, D> converterWithDestinationSupplier(Supplier<? extends D> supplier ) {
9 return ctx -> ctx.getMappingEngine().map(ctx.create(ctx.getSource(), supplier.get()));
10}
11