I am querying the database and getting the result set. When I am processing the result set I would have to set the value to the respective setter. I will be getting values like 1, 2, 3, 4, 5 and so on till 20 for one particular column.
If a value is 1 I have to assign it to setValue1() If the value is 2 then I have to assign it to setValue2() and so on till setValue20().
Example:
if(dbObject.getValue()==1) {
userObject.setfoo1(dbObject.getValue());
}
if(dbObject.getValue()==2) {
userObject.setfoo2(dbObject.getValue());
}
.
.
if(dbObject.getValue()==20) {
userObject.setfoo20(dbObject.getValue());
}
My goal is to write 1 block to achieve this functionality instead of 20 blocks that I currently have
Thanks in advance.