night-config
night-config copied to clipboard
ConversionTable for ObjectConverter - based on Target Type
Hi,
I am trying to read my (TOML-)ConfigFile into an POJO using the ObjectConverter.
I have several Durations, for example, and other custom objects. Using the @Conversion
-Annotation, I'm able to parse my file successfully.
My Question/Suggestion ist the following:
As the ObjectConverter relies on Reflection to set the Fields, it should be possible to read the field's types - wouldn't it be nice, to provide a ConversionTable selecting the converter based on the POJO's field?
Currently, as far as I understood, the ConversionTable
is applied to all Strings (or what TOML-type is specified), so it wouldn't be possible to habe a path (string) and a Duration side by side (without annotating each non-string field separately).
If the COnverter could select for all Duration- (or Whatever-)fields the Duration- (or Whatever-)Converter from the conversion table, one would have to provide the converter only once and the config POJO would be more clean.
Any thoughts on this? :-)
I can think of a nice way to do that: give a special conversion table to the ObjectConverter
, taking into account the type (toml value type) and destination type (Java field type). WDYT?
That would be cool 🙂