I'm having list of employee objects - List I need to convert it into list of employee transfer objects - List
Assume a field "password" exist in both the classes.
- In few cases i need the password needs to be included from Employee → EmployeeDTO
- In few cases i don't need the password and want to be excluded from Employee - EmployeeDTO.
Sample Code Snippet:
List<Employee> employees = employeeRepository.findAll();
// Define the target type
Type targetListType = new TypeToken<List<EmployeeDTO>>() {}.getType();
List<EmployeeDTO> employeeDTOs = modelMapper.map(employees, targetListType);
Please let me know how to skip the fields on mapping/copying.