I have a wrapper class. In that i need to access the property and its value at run time. From the code below,
Wrapper class:
public with sharing class SalesOrderWrapper implements Comparable {
public Integer OrderNo {get; set;}
public String PurchaseOrderNo {get; set;}
public String SalesOrg {get; set;}
public String Amount {get; set;}
//**********remaining code goes here**********
Now, i need to access the value of the above properties (OrderNo, PurchaseOrderNo, etc) at run time without hardcoding the syntax like this...
SalesOrderWrapper SOWrapper = (SalesOrderWrapper) compareTo;
SOWrapper.OrderNo
to something like this so that the value for "s" will be decided at the run time. Is this reflection kind of thing possible only with sObjects or with custom type too? Kindly edit the question if i did not frame the question correctly.
String s = 'OrderNo'
SOWrapper.get(s);
I know for sobject it works as below.
Account ac = new Account();
Id acId = ac.get('Id');
Is the same thing possible with custom type? Please suggest.