Type[] types = ((ParameterizedType)method.getGenericReturnType()).getActualTypeArguments();
if(types.length == 1){
try{
Class<?> clazz = (Class<?>) types[0];
PropertyDescriptor[] props = getBeanProperties(clazz);
PropertyDescriptor keyProperty = null;
PropertyDescriptor valueProperty = null;
for(PropertyDescriptor prop : props){
if(listMapKey.matcher(clazz.getName() + "." + prop.getName()).find()){
keyProperty = prop;
break;
}
}
if(listMapValue != null){
for(PropertyDescriptor prop : props){
if(listMapValue.matcher(clazz.getName() + "." + prop.getName()).find()){
valueProperty = prop;
break;
}
}
}
if(keyProperty != null){
Method keyReadMethod = keyProperty.getReadMethod();
Method valueReadMethod = valueProperty != null ? valueProperty.getReadMethod() : null;
HashMap<String,Object> map = new LinkedHashMap<String,Object>();
while(iterator.hasNext()){
Object ob = iterator.next();
map.put(String.valueOf(keyReadMethod.invoke(ob)), valueReadMethod != null ? valueReadMethod.invoke(ob) : ob);
}