Closed thomas-mc-work closed 8 years ago
That is not a bug but could be a possible improvement. It is implemented this way on purpose since one might use another processor than the default ones to do the conversion. The only situation where ParseXXX-annotations are added automatically is when there is no processor-annotation at all. In all other cases we would need to check the return type of the last CellProcessor which can not be done right now because of type-erasure and thus would require major changes.
Two possible solutions:
Suggestions welcome.
What about declaring a marker interface for data type conversion processors (like ParseInt
). If there is none of them defined then automatically select a default one derived by the variable type (via BeanCellProcessorExtractor::mapFieldToDefaultProcessor()
).
Changing processors is out of scope of this project since it is merely an addon to SuperCSV. But your suggestion is great anyway because there are already marker interfaces for primitive type conversions in the framework as far as i remember :-)
Alright, sounds good. Otherwise you could not mark the processors (which makes sense that this is out of scope) but maybe the annotations, but your approach sounds more reasonable.
When my field has the annotation
@Optional
then no corresponding processor for the data type is selected. E.g.ParseInt
is missing for allint
andInteger
fields. I would expect to have it created by the library, except when override it manually.My workaround is to define the Processor manually: