コード例 #1
0
  private void keepTraversing(Object bean, BeanMethod.Method mainMethod)
      throws BeanTraversalException {

    try {

      Map<String, Object> descriptor = PropertyUtils.describe(bean);

      descriptor.remove("class");

      Set<String> properties = descriptor.keySet();

      for (String property : properties) {

        String methodName = "get" + WordUtils.capitalize(property);

        BeanMethod beanMethod =
            bean.getClass().getMethod(methodName).getAnnotation(BeanMethod.class);

        if (beanMethod != null) traverse(descriptor.get(property), beanMethod.method());
        else traverse(descriptor.get(property), mainMethod);
      }

    } catch (Exception e) {

      throw new BeanTraversalException(e);
    }
  }