This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Couple of VO classes | |
class ParamsContainerA{ | |
int num1 | |
String text1 | |
boolean bool1 | |
} | |
class ParamsContainerB{ | |
int num2 | |
String text2 | |
boolean bool2 | |
} | |
//Couple of instances | |
ParamsContainerA anObjA=new ParamsContainerA(num1:12,text1:"holaA",bool1:true) | |
ParamsContainerB anObjB=new ParamsContainerB(num2:24,text2:"adiosB",bool2:false) | |
//Turned into Maps (filtering out the class property if desired) | |
Map mA=anObjA.properties.findAll{it.key!="class"} | |
Map mB=anObjB.properties.findAll{it.key!="class"} | |
Map result=mA+mB | |
println mA | |
println mB | |
println result |
Nota: Si el objecto no es un objeto simple sino que esta compuesto de otros objetos complejos estos campos serán mapeados igualmente pero tal cual son, sin transformarse en Maps.
No hay comentarios:
Publicar un comentario