In Android app, we use java reflection, in this discussion any tool for java object to object mapping?, it’s seen lots of library can chose on, but to use in Android, I have tried Commons-BeanUtils, Dozer, MapStruct, and ModelMapper.
Finally, it’s really easy to use if both source and target object when them are quite the same properties.
If the source target has both matching property name seen like same, like getId(), getMemberId(), getProperId(). ModelMapper mapping strategy has three type:
- LOOSE: Allows for source properties to be loosely matched to destination properties by requiring that only the last destination property in a hierarchy be matched.
- STANDARD: intelligently matched to destination properties, requiring that all destination properties be matched and all source property names have at least one token matched.
- STRICT: For source properties to be strictly matched to destination properties. This strategy allows for complete matching accuracy, ensuring that no mismatches or ambiguity occurs. But it requires that property name tokens on the source and destination side match each other precisely.
I choose STRICT, just want copy the exactly same name.