I'm new to modelMapper and I've encountered a problem when I tried to List of entity objects to a responseDTO.
User - Entity UserResponseDTO - response DTO
I did the following configurating for propertyMap.
modelMapper.addMappings(new PropertyMap<List<User>, UserResponseDTO>() {
@Override
protected void configure() {
map().setName(source.get(0).getName());
map().setEmail(source.get(0).getEmail());
map().setUserRole(source.get(0).getUserRole());
map().setLanguage(source.get(0).getLanguage());
map().setTimeZone(source.get(0).getTimeZone());
// ....have more mapping ahead
}
});
But it gives following errors:
org.modelmapper.ConfigurationException: ModelMapper configuration errors:
1) Invalid source method java.util.List.get(). Ensure that method has zero parameters and does not return void.
2) Invalid source method java.util.List.get(). Ensure that method has zero parameters and does not return void.
3) Invalid source method java.util.List.get(). Ensure that method has zero parameters and does not return void.
4) Invalid source method java.util.List.get(). Ensure that method has zero parameters and does not return void.
5) Invalid source method java.util.List.get(). Ensure that method has zero parameters and does not return void.
Can anyone tell me how can I fix this issue?