@Override @Deprecated public PropertyDescriptor findDescriptor(int col) { BeanField beanField = findField(col); if(beanField != null) { return findDescriptor(beanField.getField().getName()); } String columnName = getColumnName(col); if(StringUtils.isNotBlank(columnName)) { return findDescriptor(columnName); } return null; }
private void processProperty(T bean, String[] line, int col) throws InstantiationException, IllegalAccessException, InvocationTargetException, CsvBadConverterException { PropertyDescriptor prop = findDescriptor(col); if (null != prop) { String value = checkForTrim(line[col], prop); Object obj = convertValue(value, prop); prop.getWriteMethod().invoke(bean, obj); } }
private List<String> writeWithIntrospection(T bean, int numColumns) { PropertyDescriptor desc; List<String> contents = new ArrayList<>(numColumns > 0 ? numColumns : 0); for(int i = 0; i < numColumns; i++) { try { desc = findDescriptor(i); Object o = desc != null ? desc.getReadMethod().invoke(bean, (Object[]) null) : null; contents.add(Objects.toString(o, "")); } catch(IllegalAccessException | InvocationTargetException e) { CsvBeanIntrospectionException csve = new CsvBeanIntrospectionException( bean, null, ResourceBundle.getBundle(ICSVParser.DEFAULT_BUNDLE_NAME, errorLocale).getString("error.introspecting.beans")); csve.initCause(e); throw csve; } } return contents; }