Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BeanMapping#unmappedSourcePolicy #3309

Closed
filiphr opened this issue Jun 16, 2023 Discussed in #3308 · 1 comment · Fixed by #3326
Closed

Add BeanMapping#unmappedSourcePolicy #3309

filiphr opened this issue Jun 16, 2023 Discussed in #3308 · 1 comment · Fixed by #3326
Labels
enhancement good first issue up-for-grabs Issues targeted for community contribution
Milestone

Comments

@filiphr
Copy link
Member

filiphr commented Jun 16, 2023

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 :

  1. a first method Student toStudent(StudentDto studentDto) that can create a new Student and just fill the name and the firstname.
  2. 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 :

  1. in the first case
@BeanMapping(unmappedTargetPolicy = ReportingPolicy.IGNORE, unmappedSourcePolicy = ReportingPolicy.WARN)
Student toStudent(StudentDto studentDto);
  1. 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

@filiphr filiphr added enhancement good first issue up-for-grabs Issues targeted for community contribution labels Jun 16, 2023
@venkatesh2090
Copy link
Contributor

Hi. Is this issue still available? I would like to have a go at this.

venkatesh2090 added a commit to venkatesh2090/mapstruct that referenced this issue Jul 12, 2023
venkatesh2090 added a commit to venkatesh2090/mapstruct that referenced this issue Jul 12, 2023
venkatesh2090 added a commit to venkatesh2090/mapstruct that referenced this issue Jul 12, 2023
@filiphr filiphr added this to the 1.6.0 milestone Jul 29, 2023
venkatesh2090 added a commit to venkatesh2090/mapstruct that referenced this issue Jul 29, 2023
venkatesh2090 added a commit to venkatesh2090/mapstruct that referenced this issue Jul 29, 2023
venkatesh2090 added a commit to venkatesh2090/mapstruct that referenced this issue Jul 30, 2023
venkatesh2090 added a commit to venkatesh2090/mapstruct that referenced this issue Jul 30, 2023
venkatesh2090 added a commit to venkatesh2090/mapstruct that referenced this issue Aug 1, 2023
filiphr pushed a commit that referenced this issue Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue up-for-grabs Issues targeted for community contribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants