model mapper with page

Solutions on MaxInterview for model mapper with page by the best coders in the world

showing results for - "model mapper with page"
Gael
05 Apr 2017
1/**
2 * Maps the Page {@code entities} of <code>T</code> type which have to be mapped as input to {@code dtoClass} Page
3 * of mapped object with <code>D</code> type.
4 *
5 * @param <D> - type of objects in result page
6 * @param <T> - type of entity in <code>entityPage</code>
7 * @param entities - page of entities that needs to be mapped
8 * @param dtoClass - class of result page element
9 * @return page - mapped page with objects of type <code>D</code>.
10 * @NB <code>dtoClass</code> must has NoArgsConstructor!
11 */
12public <D, T> Page<D> mapEntityPageIntoDtoPage(Page<T> entities, Class<D> dtoClass) {
13    return entities.map(objectEntity -> modelMapper.map(objectEntity, dtoClass));
14}