There is a need for reading data from text files/excel files and populate them into objects. Below is a way to handle such population of object in a generic way. This mechanism only works for primitive type. The user defined types need to be handled in the application specific way. The code sample uses reflection to achieve this
//Pass the object that needs to be populated with a map of key
//value pair. The key is the field name and the value is the value.
//The map can be built by reading the input data.
void buildObject(Object obj, Map<String,String> mapOfValues) throws InstantiationException, IllegalAccessException{