Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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()));
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #modelmapper #abstract #class
ADD COMMENT
Topic
Name
2+9 =