code: public static void addToStringMethod(final SgClassPool pool, final SgClass clasz,
              final List<SgField> fields) {
          final SgMethod m = new SgMethod(clasz, "public", SgClass.create(pool, String.class),
                  "toString");
          m.addBodyLine("return getClass().getSimpleName() + \"{\"");
          for (int i = 0; i < fields.size(); i++) {
              final SgField field = fields.get(i);
              final String nameValue = " + \"" + field.getName() + "=\" + " + field.getName();
              if (i < fields.size() - 1) {
                  m.addBodyLine(nameValue + " + \", \"");
              } else {
                  m.addBodyLine(nameValue);
              }
          }
          m.addBodyLine(" + \"}\";");
          clasz.addMethod(m);
      }
docs: Creates an <code>toString()</code> method with all fields.
  
  @param pool
  Pool to use.
  @param clasz
  Class to add the new method to.
  @param fields
  List of fields to output.