i want to load wrapper class with one shot, but I couldn't able. may be still my oops skills are weak. i feel we can write much better way
public class WrapperA{
public Id sobjerecid;
public sobjrec__c sobjrec;
public classA classobjA;
public classB classobjB;
public WrapperA(Id recid){
this.sobjerecid= recId;
this.sobjrec = [Select Id,xy__c,ab__c,sss_c,bb__c,ccc__c from sobjec__c where Id =:recid Limit 1];
this.prepareclassA();
this.prepareclassobjB();
}
private void prepareclassA (){
classA classaobj = new classA();
classaobj.bf = 'spi';
classaobj.Sc= 'xyz';
classaobj.RS= 'abc';
classaobj.SS= '123q';
this.classobjA = classaobj;
}
private void prepareclassobjB(){
classB classBobj = new classB();
innerclassofclassB[] innerclassBlistobj = new List<innerclassofclassB>();
innerclassofclassB innerclassBobj= new innerclassofclassB();
classBobj.prop1= sobjrec.xy__c;
classBobj.prop2=sobjrec.ab__c;
classBobj.prop3 =sobjrec.sss_c;
innerclassBobj.innerclassBprop1= sobjrec.bb__c;
innerclassBobj.innerclassBprop2= sobjrec.ccc__c;
innerclassBlistobj.add(innerclassBobj);
classBobj.InnerclassB= innerclassBlistobj;
this.classobjB= classBobj;
}
}
public mainClass {
WrapperA wrapA = new WrapA(recId);// i want to load etire wrapper object with this line
}