title: Iterate over Java object methods with no args and non-void return type and print toString return value (for debugging)
body: <p>I would like to dump content of complex Java objects for debugging purpose.</p>
  
  <p>For example I want to dump of <code>toString()</code> from return value of all <code>get...()</code> methods of <code>HttpServletRequest</code> object.</p>
  
  <p>I am not interested in fields but rather in methods return values.</p>
  
  <p>I am not sure if it's possible with <code>commons-beanutils</code> or <code>ReflectionToStringBuilder.toString()</code></p>
  
  <p>Currently I implemented with <code>Introspector</code> core API:</p>
  
  <pre><code>public static String dump(Object obj, String regex) {
      StringBuilder sb = new StringBuilder();
  
      try {
          BeanInfo info = Introspector.getBeanInfo(obj.getClass());
          for (MethodDescriptor descr : info.getMethodDescriptors()) {
              String name = descr.getName();
              Method method = descr.getMethod();
              if ( ! name.matches(regex))
                  continue;
              if (method.getParameterCount() &gt; 0)
                  continue;
              if (Stream.class.isAssignableFrom(method.getReturnType()))
                  continue;
              Object objValue = method.invoke(obj);
              String strValue = Optional.ofNullable(objValue).map(Object::toString).orElse("null");
              logger.info("name: {}, value: {}", name, strValue);
              sb.append(name);
              sb.append(" =&gt; ");
              sb.append(strValue);
              sb.append("\n");
          }
      } catch (IntrospectionException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
          ex.printStackTrace();
      }
  
      return sb.toString();
  }
  </code></pre>
  
  <p>but I would like to use something standard and flexible...</p>