Modelmapper is a Java object Automatic mapping of the third-party rack package, easy to use, with Ali's Frstjson can greatly simplify the background code.
But Modelmapper Chinese use instructions very little, the official website http://modelmapper.org/explanation is also very unclear, so I studied for a long time.
Modelmapper Modelmapper =NewModelmapper (); Modelmapper.addmappings (NewPropertymap<anentity, adto>() { protected voidConfigure () {//property name is different, set the corresponding relationship yourself//source generates the target class, destination the data source class, these two words can be interpreted as two pointers, substituting the reference classmap (). SetText (Source.getdescription ()); //Some properties are not mapped//property is an object that can be as followsSkip (). Setdtoonlyproperty (NULL); //property is not an object'sSkip (Destination.getid ());//you can set the properties on the source, or you can set the properties of the destination } }); Adto Adto= Modelmapper.map (Entity, adto.class);
More advanced applications can refer to http://www.talangsoft.org/2015/04/20/domain_mapping_with_modelmapper/this English blog, there is no way to Chinese too little ~ ~
Hope this article is helpful to everyone, after all, the study of playing a few hours head is dizzy ~ ~ by the way, modelmapper performance is not very good (but also after the ghosts know the cycle of the less, but their own less a lot of also recognized) to correct use or there will be a stutter ~ ~
Modelmapper advanced use of Java