return field.get(aModel);
}
} catch (NoSuchFieldException e) {
// do nothing
} catch (IllegalAccessException e) {
throw new ModelDeficientPropertyException("field: " + key, e);
} catch (RuntimeException e) {
throw new ModelDeficientPropertyException("field: " + key, e);
}
String getterMethod = "get" + Character.toUpperCase(key.charAt(0)) + key.substring(1);
try {
Method getter = modelClass.getMethod(getterMethod);
if (getter != null && Modifier.isPublic(getter.getModifiers())) {
return getter.invoke(aModel);
}
} catch (NoSuchMethodException e) {
// do nothing
} catch (InvocationTargetException e) {
throw new ModelDeficientPropertyException("getter method: " + getterMethod, e);
} catch (IllegalAccessException e) {
throw new ModelDeficientPropertyException("getter method: " + getterMethod, e);
} catch (RuntimeException e) {
throw new ModelDeficientPropertyException("getter method: " + getterMethod, e);
}
try {
Method method = modelClass.getMethod(key);
if (method != null && Modifier.isPublic(method.getModifiers())) {
return method.invoke(aModel);
}
} catch (NoSuchMethodException e) {
// do nothing
} catch (InvocationTargetException e) {
throw new ModelDeficientPropertyException("method: " + key, e);
} catch (IllegalAccessException e) {
throw new ModelDeficientPropertyException("method: " + key, e);
} catch (RuntimeException e) {
throw new ModelDeficientPropertyException("method: " + key, e);
}
throw new ModelDeficientPropertyException("key: " + key);
}