Modelmapper use of the Pojo mapper

Source: Internet
Author: User

In recent project development, a lot of domain models have been used, (POJO refers only to setter/getter/tostring simple classes, including DO/DTO/BO/VO, etc.), and then encounters many scenarios where the model attributes are automatically converted,

Initial direct use of the Set,get method, but led to a large number of garbage code, and later research, found that can be used by some tool classes to complete the conversion

Beanutils.copyproperties (source, target), which can copy properties by the same type as the same name, but is limited to efficiency and cannot be customized for extension.

Modelmapper modelmapper = new Modelmapper (); Target =modelmapper.map (source,class<z>); The advantage of this method is that you can customize the transformation relationship, implement different properties, different types of properties of the replication, the application is very broad, but there are some drawbacks, is that no property will be null value


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.