Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Converter private final Function from Dto; private final Function fromEntity; /** * Constructor. * @param from Dto Function that converts given dto entity

image text in transcribed

public class Converter private final Function from Dto; private final Function fromEntity; /** * Constructor. * @param from Dto Function that converts given dto entity into the domain entity. * @param fromEntity Function that converts given domain entity into the dto entity. */ public Converter(Final Function from Dto, final Function fromEntity) ( this.fromDto = from Dto; this.fromEntity = fromEntity; } /** * Converts DTO to Entity. * * @param dto DTO entity * @return The domain representation - the result of the converting function application on dto entity. *7 public final U convertFromDto(final T dto) ! return from Dto.apply(dto); } * Converts Entity to DTO. * @param entity domain entity * @return The DTO representation - the result of the converting function application on domain entity. / public final T convertFromEntity(final U entity) { return fromEntity.apply(entity); 3 /** * Converts list of DTOs to list of Entities. @param dtos collection of DTO entities * @return List of domain representation of provided entities retrieved by mapping each of them with the conversion function *1 public final List createFromDtos(final Collection dtos) { return dtos.stream().map(this::convertFrom Dto).collect(Collectors.toList(); 3 /** * Converts list of Entities to list of DTOS. * @param entities collection of domain entities * @return List of domain representation of provided entities retrieved by mapping each of them with the conversion function */ public final List createFromEntities(final Collection entities) return entities.stream().map(this::convertFromEntity).collect(Collectors.toList()); ) 3 public class Converter private final Function from Dto; private final Function fromEntity; /** * Constructor. * @param from Dto Function that converts given dto entity into the domain entity. * @param fromEntity Function that converts given domain entity into the dto entity. */ public Converter(Final Function from Dto, final Function fromEntity) ( this.fromDto = from Dto; this.fromEntity = fromEntity; } /** * Converts DTO to Entity. * * @param dto DTO entity * @return The domain representation - the result of the converting function application on dto entity. *7 public final U convertFromDto(final T dto) ! return from Dto.apply(dto); } * Converts Entity to DTO. * @param entity domain entity * @return The DTO representation - the result of the converting function application on domain entity. / public final T convertFromEntity(final U entity) { return fromEntity.apply(entity); 3 /** * Converts list of DTOs to list of Entities. @param dtos collection of DTO entities * @return List of domain representation of provided entities retrieved by mapping each of them with the conversion function *1 public final List createFromDtos(final Collection dtos) { return dtos.stream().map(this::convertFrom Dto).collect(Collectors.toList(); 3 /** * Converts list of Entities to list of DTOS. * @param entities collection of domain entities * @return List of domain representation of provided entities retrieved by mapping each of them with the conversion function */ public final List createFromEntities(final Collection entities) return entities.stream().map(this::convertFromEntity).collect(Collectors.toList()); ) 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions