Is there a way to map collection size in dozer?
class Source {
Collection<String> images;
}
class Destination {
int numOfImages;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
EDIT: I’ve updated my answer to use a custom converter at the field level instead of at the class level.
There might be other solutions but one way to do this would be to use a Custom Converter. I’ve added getters and setters to your classes and wrote the following converter:
Then, declare it in a custom XML mapping file:
With this setup, the following test passes successfully: