-
Notifications
You must be signed in to change notification settings - Fork 343
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 value reader for records #715
add value reader for records #715
Conversation
Hi, I found bug here. class Test{
UUID userId;
}
record TestDto(UUID userId){}
Test test = modelMapper.map(new TestDto(UUID.randomUUID()), Test.class) In this code, the test.userId is null. |
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
I got solution. @Override
public Member<Record> getMember(Record record, String memberName) {
Field field = matchField(record, memberName);
Class<?> type = field != null ? field.getType() : Record.class;
return new Member<>(type) {
@Override
public Object get(Record source, String memberName) {
return RecordValueReader.this.get(source, memberName);
}
};
} You use |
@yangyaofei |
CI failed, but record doesn't exist in java8, so this would not success. |
There're still a lot of users using java 8, so upgrade java version is not an option. How about creating separated module? |
means using actually, I found something like that. Maybe you can use this extension... |
ModelMapper modelMapper = new ModelMapper();
modelMapper.getConfiguration().addValueReader(new RecordValueReader()); I use your code like this. It's good. |
@yangyaofei @Configuration
public class JavaConfig {
@Bean
public ModelMapper modelMapper() {
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().addValueReader(new RecordValueReader());
return mapper;
}
}
actually, I'm not sure what specific actions to take based on the feedback provided. |
Thanks @okaponta for the contribution. Moved the code into separated repository https://github.com/modelmapper/modelmapper-module-record and I also had a released |
#546
support
Record
->POJO
POJO
->Record
is unimplemented, see below for details.#546 (comment)