class ObjectUtil {

    public void trimStringValues(Object object) {
        Class<?> clazz = object.getClass();
        while (clazz != null) {
            for (Field field : clazz.getDeclaredFields()) {
                trimField(object, field);
            }
            clazz = clazz.getSuperclass();
        }
    }

}