Hi sheriff,
Apologies for delayed reply. Thanks for your inputs. I have implemented the thing which I asked about using java.beans and java.lang.reflect.
I am keeping the field names in a properties file mapped to some keys and then reading the field names to retrieve the getter methods.
The main issue I had was to get rid of several if/else statements to populate the JSON object based upon the fields in the
java bean. For e.g I am reading set of field names which needs to go in JSON object from a property file and then based on that had logic with if.else to call individual method. I didnt like that way of programming so looking for this solution.
Thoughts
1) Another thing which is coming to my mind is that if getter has various return types(of course it will have in practical scenario) then will I end up writing the if..else to check the datatype and populate the values in another bean or whatever.
Anyways I did not face the issue mentioned above(Thoughts 1) because I am straight away putting whatever value returned (m.invoke() returns Object) in the JSON object which has all the strings.
Just wanted to surface what came in my mind hence wrote the above issue.
Thanks once again
Amit