Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- You can achieve it with the `@Qualifier`. You can use `@Named` and `qualifiedByName`, or you can use your own custom `@CountryWithoutCities` qualifier with `qualifiedBy`
- ```java
- interface CountryMapper {
- @Mapping( target = "cities", qualifiedByName = "noCountry")
- CountryDto toDto(Country country);
- @CountryWithoutCities
- @Mapping( target = "cities", ignore = true)
- CountryDto toDtoWithoutCities(Country country);
- }
- interface CityMapper {
- @Named( "noCountry" )
- @Mapping( target = "country", ignore = true)
- CityDto toDtoWithoutCountry(City city);
- @Mapping( target = "country", qualifiedBy= CountryWithoutCities.class)
- CityDto toDto(City city);
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement