尝试为list类型的字段赋值

@param datas 转换后的数据
@param pojo  要赋值的pojo
@param field 要赋值的字段说明
@param clazz 集合的Class对象
@return 返回true表示赋值成功，返回false表示赋值失败
499375
@SuppressWarnings("unchecked")
    private boolean trySetValue(List<?> datas, Object pojo, CustomPropertyDescriptor field,
                                Class<? extends Collection> clazz) {
        log.debug("要赋值的fieldName为{}", field.getName());

        Collection collection = tryBuildCollection(clazz);
        if (collection == null) {
            log.warn("无法为class[{}]构建实例", clazz);
            return false;
        }
        collection.addAll(datas);
        try {
            return BeanUtils.setProperty(pojo, field.getName(), collection);
        } catch (Exception e) {
            log.debug("字段[{}]赋值失败，使用的集合类为[{}]", field.getName(), clazz, e);
            return false;
        }
    }
990901
public static boolean isNotPojo(Class<?> clazz) throws NullPointerException {
        Assert.notNull(clazz, "clazz不能为null");
        return Boolean.class.isAssignableFrom(clazz) || Character.class.isAssignableFrom(clazz)
               || Number.class.isAssignableFrom(clazz) || Map.class.isAssignableFrom(clazz)
               || String.class.isAssignableFrom(clazz) || Collection.class.isAssignableFrom(clazz)
               || Enum.class.isAssignableFrom(clazz) || isGeneralType(clazz);
    }
6787
public static <T> List<Field> getAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotationClass) {
		List<Field> annotatedFields = new LinkedList<Field>();
		Field[] allFields = getAllDeclaredFields(clazz);
		for (Field field : allFields) {
			if (null != (field.getAnnotation(annotationClass))) {
				annotatedFields.add(field);
			}
		}
		return annotatedFields;
	}
211287
public static List<Field> getAllFields(Class<?> clas) {
		JK.fixMe("add caching..");
		List<Field> list = new Vector<>();
		// start by fields from the super class
		if (clas.getSuperclass() != null) {
			list.addAll(getAllFields(clas.getSuperclass()));
		}
		Field[] fields = clas.getDeclaredFields();
		for (Field field : fields) {
			if (!Modifier.isStatic(field.getModifiers())) {
				list.add(field);
			}
		}
		return list;
	}
1298679
public static List<JBBPAbstractField> fieldsAsList(final JBBPAbstractField... fields) {
    final List<JBBPAbstractField> result = new ArrayList<>();
    Collections.addAll(result, fields);
    return result;
  }
18907
public static List<FieldInfo> fetchFieldInfos(Class cls, boolean ignoreNoAnnotation) {
        // if set ProtobufClass annotation
        Annotation annotation = cls.getAnnotation(ProtobufClass.class);

        Annotation zipZap = cls.getAnnotation(EnableZigZap.class);
        boolean isZipZap = false;
        if (zipZap != null) {
            isZipZap = true;
        }

        boolean typeDefined = false;
        List<Field> fields = null;
        if (annotation == null) {
            fields = FieldUtils.findMatchedFields(cls, Protobuf.class);
            if (fields.isEmpty() && ignoreNoAnnotation) {
                throw new IllegalArgumentException("Invalid class [" + cls.getName() + "] no field use annotation @"
                        + Protobuf.class.getName() + " at class " + cls.getName());
            }
        } else {
            typeDefined = true;

            fields = FieldUtils.findMatchedFields(cls, null);
        }

        List<FieldInfo> fieldInfos = ProtobufProxyUtils.processDefaultValue(fields, typeDefined, isZipZap);
        return fieldInfos;
    }
342616
public <T> T[] convert(Object[] datas, Class<T> clazz) {
    if (null == datas) { return null; }
    @SuppressWarnings("unchecked")
    T[] newDatas = (T[]) Array.newInstance(clazz, datas.length);
    for (int i = 0; i < datas.length; i++) {
      newDatas[i] = convert(datas[i], clazz);
    }
    return newDatas;
  }
21604
public static <T extends Annotation> Set<Field> getAnnotatedPublicFields(Class<? extends Object> clazz,
			Class<T> annotation) {

		if (Object.class.equals(clazz)) {
			return Collections.emptySet();
		}

		Set<Field> annotatedFields = new HashSet<Field>();
		Field[] fields = clazz.getFields();

		for (Field field : fields) {
			if (field.getAnnotation(annotation) != null) {
				annotatedFields.add(field);
			}
		}

		return annotatedFields;
	}
1087004
public boolean hasField(@NonNull String fieldName) {
      return ClassDescriptorCache.getInstance()
                                 .getClassDescriptor(clazz)
                                 .getFields(accessAll)
                                 .stream()
                                 .anyMatch(f -> f.getName().equals(fieldName));
   }
20785
private static void setListParam(Field field, List<?> values) {
        try {
            // Find method: clear() and call it
            Class<?> fieldClass = field.getType();
            Method clearMethod = fieldClass.getMethod("clear");
            clearMethod.invoke(field.get(config));
            
            // Find List method: add(Object) 
            Method addMethod = fieldClass.getMethod("add", Object.class);
            
            // Add each map key/value to field value
            for (Object subParam : values) {
                if (subParam instanceof String) {
                    addMethod.invoke(field.get(config), subParam);
                } else {
                    throw new RuntimeException("Unexpected parameter type for '" + field.getName() + ":" + subParam);
                }
            }
        } catch (NoSuchMethodException  | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
            throw new RuntimeException("Error setting configuration parameter '" + field.getName() + "'", e);
        }
    }
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()]);
		}
	}
243522
private static List<Field> getFieldsList(final Class cls, final boolean declared) {
		$.checkNotNull(cls);

		final List<Field> allFields = new ArrayList<Field>();
		Class currentClass = cls;
		while (currentClass != null) {
			final Field[] declaredFields = declared ? currentClass.getDeclaredFields() : currentClass.getFields();
			for (Field field : declaredFields) {
				allFields.add(field);
			}
			currentClass = currentClass.getSuperclass();
		}
		return allFields;
	}
696653
public List list(Class clazz, String key, Object value)
    {
        EntityManager entityManager = null;
        try {
            entityManager = entityManagers.poll();

            Query query = entityManager.createQuery("SELECT c FROM " + clazz.getCanonicalName() + " c where c." + key + " = :param");
            query.setParameter("param", value);
            return query.getResultList();

        } catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            if(entityManager != null)
                entityManagers.add(entityManager);
        }

        return null;
    }
43693
public static List<Field> getDeclaredFields(@NonNull Class<?> clazz, boolean recursive) {
      List<Field> fields = new ArrayList<>();
      do {
         fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
         clazz = clazz.getSuperclass();
      } while (recursive && clazz != null && clazz != Object.class);
      return fields;
   }
1146442
public void registerClass(Class<?> clazz) {
        registeredClasses.add(clazz);
        for (Field field : clazz.getFields()) {
            if (field.isAnnotationPresent(Opt.class)) {
                int mod = field.getModifiers();
                if (!Modifier.isPublic(mod)) { throw new IllegalStateException("@"+Opt.class.getName()+" on non-public field: " + field); }
                if (Modifier.isFinal(mod)) { throw new IllegalStateException("@"+Opt.class.getName()+" on final field: " + field); }
                if (Modifier.isAbstract(mod)) { throw new IllegalStateException("@"+Opt.class.getName()+" on abstract field: " + field); }

                // Add an Apache Commons CLI Option for this field.
                Opt opt = field.getAnnotation(Opt.class);

                String name = getName(opt, field);
                if (!names.add(name)) {
                    throw new RuntimeException("Multiple options have the same name: --" + name);
                }

                String shortName = null;
                if (createShortNames) {
                    shortName = getAndAddUniqueShortName(name);
                }
                
                Option apacheOpt = new Option(shortName, name, opt.hasArg(), opt.description());                    
                apacheOpt.setRequired(opt.required());
                options.addOption(apacheOpt);

                optionFieldMap.put(apacheOpt, field);

                // Check that only boolean has hasArg() == false.
                if (!field.getType().equals(Boolean.TYPE) && !opt.hasArg()) {
                    throw new RuntimeException("Only booleans can not have arguments.");
                }
            }
        }
    }
461498
public List<Object> getAsList(String field, String separator) {
        Object value = get(field);
        if (value == null) {
            return Collections.emptyList();
        } else {
            if (value instanceof List) {
                return (List) value;
            } else {
                return Arrays.<Object>asList(value.toString().split(separator));
            }
        }
    }
36632
private static List<Field> _getAnnotationColumns(Class<?> clazz, 
			Class<? extends Annotation> annoClazz) {
		if(clazz == null) {
			return new ArrayList<Field>();
		}
		
		List<Class<?>> classLink = new ArrayList<Class<?>>();
		Class<?> curClass = clazz;
		while (curClass != null) {
			classLink.add(curClass);
			curClass = curClass.getSuperclass();
		}
		
		return _getFields(classLink, annoClazz);
	}