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.
356033
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);
    }
16583
public static List<Field> getAllFields(Class<?> clazz) {
        final List<Field> ret = new ArrayList<>();
        do {
            ret.addAll(Arrays.asList(clazz.getDeclaredFields()));
            clazz = clazz.getSuperclass();
        } while (clazz != null);
        return ret;
    }
205156
public void fieldsToString (StringBuilder builder)
    {
        builder.append("hostname=").append(_hostname);
        if (_ports != null && _ports.length > 0) {
            builder.append(", ports=");
            StringUtil.toString(builder, _ports);
        }
        if (_datagramPorts != null && _datagramPorts.length > 0) {
            builder.append(", datagramPorts=");
            StringUtil.toString(builder, _datagramPorts);
        }
        builder.append(", clOid=").append(_cloid);
        builder.append(", connId=").append(_connectionId);
        builder.append(", creds=");
        StringUtil.toString(builder, _creds);
    }
156223
public static Field[] jlClassGetFields(Class<?> clazz) {
		ReloadableType rtype = getRType(clazz);
		if (rtype == null) {
			return clazz.getFields();
		}
		else {
			List<Field> allFields = new ArrayList<Field>();
			gatherFields(clazz, allFields, new HashSet<Class<?>>());
			return allFields.toArray(new Field[allFields.size()]);
		}
	}
1301075
public static final <T> Field getField(Class<T> cls, String fieldName) {
        try {
            Field f = cls.getDeclaredField(fieldName);
            f.setAccessible(true);
            return f;
        } catch (SecurityException e) {
            throw new RuntimeException(e);
        } catch (NoSuchFieldException e) {
            if (cls.getSuperclass() != null) {
                return getField(cls.getSuperclass(), fieldName);
            }
            throw new RuntimeException(e);
        }
    }
1321888
public Field[] getFields(Class clazz, String fieldname) {
	Struct fieldMap;
	Object o;
	synchronized (map) {
	    o = map.get(clazz);
	    if (o == null) {
		fieldMap = store(clazz);
	    }
	    else fieldMap = (Struct) o;
	}
	o = fieldMap.get(fieldname, null);
	if (o == null) return null;
	return (Field[]) o;

    }
837739
public static Field getField(Class<?> clazz, String fieldName)
      throws NoSuchFieldException {
    if (clazz == Object.class) {
      return null;
    }
    try {
      Field field = clazz.getDeclaredField(fieldName);
      return field;
    } catch (NoSuchFieldException e) {
      return getField(clazz.getSuperclass(), fieldName);
    }
  }
523002
public static Field getDeclaredField(Class<?> clz, final String fieldName) {
    for (Class<?> s = clz; s != Object.class; s = s.getSuperclass()) {
      try {
        return s.getDeclaredField(fieldName);
      } catch (NoSuchFieldException ignored) {
      }
    }
    return null;
  }
557890
public static Collection<Field> fields(final Class<?> cls) {
		Map<String, Field> fieldMap = new HashMap<>();
		walkFields(cls, fieldMap);
		return fieldMap.values();
	}
82083
protected Collection<Field> getSessionFields(Class<?> clazz) {
        Collection<Field> fields = fieldMap.get(clazz);
        if (fields == null) {
            fields = ReflectUtil.getFields(clazz);
            Iterator<Field> iterator = fields.iterator();
            while (iterator.hasNext()) {
                Field field = iterator.next();
                if (!field.isAnnotationPresent(Session.class)) {
                    iterator.remove();
                }
            }
            fieldMap.put(clazz, fields);
        }
        return fields;
    }
1298679
public static List<JBBPAbstractField> fieldsAsList(final JBBPAbstractField... fields) {
    final List<JBBPAbstractField> result = new ArrayList<>();
    Collections.addAll(result, fields);
    return result;
  }
387163
protected void toStringFields(final StringBuffer buffer) {

        buffer.append("<managedConnectionFactory=");
        buffer.append(_managedConnectionFactory);
        buffer.append("> <coreConnection=");
        buffer.append(_coreConnection);
        buffer.append("> <localTransaction=");
        buffer.append(_localTransaction);
        buffer.append("> <xaResource=");
        buffer.append(_xaResource);
        buffer.append("> <metaData=");
        buffer.append(_metaData);
        buffer.append("> <userDetails=");
        buffer.append(_userDetails);
        buffer.append("> <subject=");
        buffer.append(subjectToString(_subject));
        buffer.append("> <logWriter=");
        buffer.append(_logWriter);
        buffer.append("> <sessions=");
        buffer.append(_sessions);

        // Don't call toString on listeners as this will result in recursive calls under JBoss and a StackOverFlow
        buffer.append("> <connectionListeners=[");
        for (int i = 0; i < _connectionListeners.size(); i++) {
            Object o = _connectionListeners.get(i);
            if (i > 0)
                buffer.append(",");
            buffer.append(o.getClass().getName() + "@" + o.hashCode());
        }
        buffer.append("]>");

    }
631562
private static Field matchClassField(Class clazz, String fieldName) {

        List<Field> fields = new ArrayList<>();
        for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
            fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
        }
        for (Field field : fields) {
            if (fieldName.equals(field.getName())) {
                return field;
            }
        }
        throw new IllegalArgumentException("[" + clazz.getName() + "] can`t found field with [" + fieldName + "]");
    }
776073
public static String printToString(UnknownFieldSet fields) {
        try {
            StringBuilder text = new StringBuilder();
            print(fields, text);
            return text.toString();
        } catch (IOException e) {
            throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never "
                                                       + "happen).",
                                       e);
        }
    }
1191603
public static void setFieldValue(final Object object, final Class<?> clazz, final String fieldName,
            final Object value) throws NoSuchFieldException {
        final Field field = clazz.getDeclaredField(fieldName);

        try {
            setField(field, object, value);
        } catch (final Exception e) {
            LOG.error(e.getMessage(), e);
        }
    }
360721
List<SyntheticField> makeSynthetic(Class<?> clazz, List<Field> fields) {
        List<SyntheticField> result = new ArrayList<>();
        for (Field field : fields) {
            result.add(new AccessorSyntheticField(this, clazz, field));
        }
        return result;
    }
463377
private static List<Field> getAllFields(Class<?> clazz){
		if(!clazz.equals(Object.class)){
			List<Field> fields = new ArrayList<Field>(Arrays.asList(clazz.getDeclaredFields()));
			List<Field> fields2 = getAllFields(clazz.getSuperclass());
			if(fields2!=null){
				fields.addAll(fields2);
			}
			return fields;
		}else{
			return null;
		}
	}