Skip to content

Add BeanMapping#unmappedSourcePolicy #3309

@filiphr

Description

@filiphr

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions