Exemple #1
0
  private Object getBeanValue(Object bean, String property) {
    String getterMethodName = ClassUtil.toGetterName(property);
    Method getterMethod = ClassUtil.getGetterMethod(getterMethodName, bean, null);

    if (getterMethod == null) {
      getterMethodName = ClassUtil.toIsGetterName(property);
      getterMethod = ClassUtil.getGetterMethod(getterMethodName, bean, null);
    }

    if (getterMethod != null) {
      try {
        return getterMethod.invoke(bean);
      } catch (Exception e) {
        throw new IllegalStateException(
            "Error invoking getter method '"
                + getterMethodName
                + "' on Object type '"
                + bean.getClass().getName()
                + "'.",
            e);
      }
    }

    return null;
  }