When there is an List
, is there a possibility of getting List of all person.getName()
out of that?
Is there an prepared call for that
Not tested but this is the idea:
public static List getAttributeList(List list, Class extends Q> clazz, String attribute)
{
List attrList= new ArrayList();
attribute = attribute.charAt(0).toUpperCase() + attribute.substring(1);
String methodName = "get"+attribute;
for(Object obj: personList){
T aux = (T)clazz.getDeclaredMethod(methodName, new Class[0]).invoke(obj, new Object[0]);
attrList.add(aux);
}
}