Bootstrap

反射避开field.setAccessible(true); field.set(t, lineArray[i]); 赋值

Reflection should not be used to increase accessibility of classes, methods, or fields

public <T> T toJavaObject(String line) throws Exception {
    // 数据组文件没有标题行 单独处理
    if (StringUtils.isBlank(line)) {
        return null;
    } else {
        String[] lineArray = line.split(SymbolConstants.COMMA, -1);
        Class<T> clazz = getFileType().findClass();
        T t = clazz.newInstance();
        Field[] fields = clazz.getDeclaredFields();
        int i = 0;
        for (Field field : fields) {
            // field.setAccessible(true);
            // field.set(t, lineArray[i]);
            setBodyValueByField(t, field, lineArray[i]);
            i++;
        }
        return t;
    }
}

private void setBodyValueByField(Object t, Field field, String stringValue) {
    try {
        Class<?> clazz = t.getClass();
        PropertyDescriptor pd = new PropertyDescriptor(field.getName(), clazz);
        Met
;