Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. You can achieve it with the `@Qualifier`. You can use `@Named` and `qualifiedByName`, or you can use your own custom `@CountryWithoutCities` qualifier with `qualifiedBy`
  2.  
  3. ```java
  4. interface CountryMapper {
  5.  
  6. @Mapping( target = "cities", qualifiedByName = "noCountry")
  7. CountryDto toDto(Country country);
  8.  
  9. @CountryWithoutCities
  10. @Mapping( target = "cities", ignore = true)
  11. CountryDto toDtoWithoutCities(Country country);
  12. }
  13.  
  14. interface CityMapper {
  15.  
  16. @Named( "noCountry" )
  17. @Mapping( target = "country", ignore = true)
  18. CityDto toDtoWithoutCountry(City city);
  19.  
  20. @Mapping( target = "country", qualifiedBy= CountryWithoutCities.class)
  21. CityDto toDto(City city);
  22. }
  23. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement