package service.mappy;

import model.GenericBuilder;
import model.computer.Computer;
import service.mappy.computer.ComputerDTO;

public class ComputerMapper implements Mapper<Computer, ComputerDTO> {
    /**
     * Computer from ComputerDTO.
     * @param computerDTO in
     * @return Computer
     */
    @Override
    public Computer from(ComputerDTO computerDTO) {
        return GenericBuilder.of(Computer::new)
                .with(Computer::setId, computerDTO.getId())
                .with(Computer::setName, computerDTO.getName())
                .build();
    }

    /**
     * Computer to ComputerDTO.
     * @param computer in
     * @return ComputerDTO
     */
    @Override
    public ComputerDTO to(Computer computer) {
        return GenericBuilder.of(ComputerDTO::new)
                .with(ComputerDTO::setId, computer.getId())
                .with(ComputerDTO::setName, computer.getName())
                .build();
    }
}
@@ -42,24 +42,54 @@
 ricBuilder;%0A
+import model.company.Company;%0A
 import model
@@ -150,16 +150,52 @@
 uterDTO;
+%0Aimport service.validator.Validator;
 %0A%0Apublic
@@ -621,349 +621,1275 @@
    .
-build();%0A    %7D%0A%0A    /**%0A     * Computer to ComputerDTO.%0A     * @param computer in%0A     * @return ComputerDTO%0A     */%0A    @Override%0A    public ComputerDTO to(Computer computer) %7B%0A        return GenericBuilder.of(ComputerDTO::new)%0A                .with(ComputerDTO::setId, computer.getId())%0A                .with(ComputerDTO::setName, computer
+with(Computer::setIntroduced, Validator.parseString(computerDTO.getIntroduced()))%0A                .with(Computer::setDiscontinued, Validator.parseString(computerDTO.getDiscontinued()))%0A                .with(Computer::setCompany, computerDTO.getCompanyId() %3C 1 ? null :%0A                        GenericBuilder.of(Company::new)%0A                        .with(Company::setId, computerDTO.getCompanyId())%0A                        .with(Company::setName, computerDTO.getCompanyName())%0A                        .build())%0A                .build();%0A    %7D%0A%0A    /**%0A     * Computer to ComputerDTO.%0A     * @param computer in%0A     * @return ComputerDTO%0A     */%0A    @Override%0A    public ComputerDTO to(Computer computer) %7B%0A        return GenericBuilder.of(ComputerDTO::new)%0A                .with(ComputerDTO::setId, computer.getId())%0A                .with(ComputerDTO::setName, computer.getName())%0A                .with(ComputerDTO::setIntroduced, computer.getIntroduced())%0A                .with(ComputerDTO::setDiscontinued, computer.getDiscontinued())%0A                .with(ComputerDTO::setCompanyId, computer.getCompany() == null ? null : computer.getCompany().getId())%0A                .with(ComputerDTO::setCompanyName, computer.getCompany() == null ? null : computer.getCompany()
 .get

fix ComputerMapper bug