42BV / CSVeed

Light-weight, easy-to-use Java-based CSV utility
Apache License 2.0
100 stars 22 forks source link

Handling of null/empty values could be improved #118

Open hvennekate opened 4 years ago

hvennekate commented 4 years ago

https://github.com/robert-bor/CSVeed/blob/31d23f728e7a4b09aa91d5c443c3fc8f5067d428/src/main/java/org/csveed/bean/conversion/BeanWrapper.java#L39

This choice appears unreasonable from the user's perspective: it is not possible to customize the behavior as the converter does not get called. At the same time, any previously initialized value gets overwritten. Please either do not touch the existing value (from field initialization) or offer some hook into this process such that null and empty values can be mapped to some reasonable default.

hazendaz commented 1 year ago

@hvennekate Know this is old but are you saying it should be something like this?

Current

 writeMethod.invoke(bean, value == null || value.equals("") ? null : converter.fromString(value));

New

 writeMethod.invoke(bean, converter.fromString(value));