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