Reputation: 55
I created a couple of DTO's and a MapStruct interface for getting the User data:
public class UserDto {
private Long id;
private CountryDto country;
}
public class CountryDto {
private Long id;
private String name;
private List<TimeZoneDto> timeZones = new ArrayList<TimeZoneDto>();
}
@Mapper
public interface UserMapper {
UserMapper INSTANCE = Mappers.getMapper(UserMapper.class);
// TODO exclude country timezones
UserDto mapToDto(User entity);
}
I would like to modify UserMapper so the CountryDto timezones list are excluded
{
"id":1,
"country": {
"id": 182,
"name":"Australia"
}
}
Upvotes: 0
Views: 1188
Reputation: 55
I finally found a solution for this, just adding the line below in UserMapper did the trick:
@Mapping(target = "country.timeZones", ignore = true)
UserDto mapToDto(User entity);
Upvotes: 4