-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Discussed in #3308
Originally posted by meilleureVie June 15, 2023
There is some case both BeanMapping#unmappedSourcePolicy and BeanMapping#unmappedTargetPolicy will be helpful.
let take an example of 2 class (class Student with more than 20 properties and StudentDto with 2 attributes just name and firstname)
So in our mapper we are looking for 2 methods :
- a first method Student toStudent(StudentDto studentDto) that can create a new Student and just fill the name and the firstname.
- a second method StudenDto toStudentDto(Student student) that can map the name and firstname of a student to studentDto
For me, in order to achieve that goal and also take advantage of typesafe warning, it will be easier for me to do something like this :
- in the first case
@BeanMapping(unmappedTargetPolicy = ReportingPolicy.IGNORE, unmappedSourcePolicy = ReportingPolicy.WARN)
Student toStudent(StudentDto studentDto);
- in the second case
@BeanMapping(unmappedTargetPolicy = ReportingPolicy.WARN, unmappedSourcePolicy = ReportingPolicy.IGNORE)
StudentDto toStudentDto(Student student);
But i don't know why BeanMapping#unmappedSourcePolicy does not exists ?
So i'm wondering why and also wondering if you plan another best way to achieve that goal.
thanks
Note: This is an easy issue, so if someone from the community is interested in working on this please let us know