java - Map an array to a complex type using Dozer -


i able map array complex type specified in 1 of answers in link. application contains more 500 classes , time consuming identify , map these 1 one. trying build generic method conversion. example , complex type array can achieved using following methods. looking ways reverse operation -

public <t> t map(object srcobj, class<?> destclass, string mapid) {     if (srcobj == null) {         return null;     }      if (srcobj.getclass().isarray()) {         return (t) maparraytoarray((object[]) srcobj, destclass);     }      return (t) dozerbeanmapper.map(srcobj, destclass, mapid); }  private object maparraytoarray(object[] srcarray, class<?> destclass) {     class<?> componenttype = destclass.getcomponenttype();     object resultarray = array.newinstance(componenttype, srcarray.length);      (int = 0; < srcarray.length; i++) {         object resultitem = this.map(srcarray[i], componenttype);         array.set(resultarray, i, resultitem);     }      return resultarray; } 


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -