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

expect "Several possible source properties for target property" for both plain and pojo parameter but not #3535

Open
xpcpku opened this issue Feb 21, 2024 · 2 comments
Labels

Comments

@xpcpku
Copy link

xpcpku commented Feb 21, 2024

Expected behavior

Here is my code

public class Pojo {
  String id;
  // ignore getter/setter and other fields
}

@Mapper
public interface MyConverter {
  Pojo toPojo(String id, Pojo source);
}

In this toPojo method, field id contains 2 sources, one from id parameter, the other from source object, I expect a "Several possible source properties for target property" error but it uses source.id directly.

Actual behavior

no error

Steps to reproduce the problem

default configuration

MapStruct Version

MapStruct 1.5.5.Final

@xpcpku xpcpku added the bug label Feb 21, 2024
@filiphr
Copy link
Member

filiphr commented Feb 25, 2024

This works as designed, the highest priority is properties of the source parameters. Then as as second step it is going to check if the source parameter name matches a target property.

See https://mapstruct.org/documentation/stable/reference/html/#mappings-with-several-source-parameters

@xpcpku
Copy link
Author

xpcpku commented Feb 27, 2024

Got it, is it possible to add a config item to enforce the check? in case of adding the new POJO parameter into the existing mapping method, actually the source of mapping might be change and it will be helpful to let the develop know.

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants