Implement conversion method for string-based configurations.


A recent refactoring improved the configuration classes so that anything extending BaseConfiguration<T> has a convertValue(@Nonnull final Optional<T> value, @Nonnull final Class<C> convertClass) method for converting from the underlying storage values to the requested type. However it appears that even though AbstractStringConfiguration now extends BaseConfiguration, it wasn't completely updated to use convertValue(); its values are still being converted in findObject(final String key, final Class<O> type).

Move the conversion logic in from AbstractStringConfiguration from findObject() to convertValue() so that the conversion logic can be consolidated and reused. Moreover after this change AbstractStringConfiguration.findObject() can probably be removed altogether, allowing the implementation from BaseConfiguration to be used (which calls convertValue()).




Garret Wilson
December 22, 2019, 6:49 PM

The small additional complication is that AbstractStringConfiguration.findObject() calls findBoolean() if a Boolean type was requested. Rather than duplicating the functionality in AbstractStringConfiguration.findBoolean(), it would probably be best to promote AbstractObjectConfiguration.findBoolean() (which delegates to convertValue()) to BaseConfiguration. Then all string conversion could be consolidated in AbstractStringConfiguration.convertValue() (except maybe the primitive OptionalXXX versions, for efficiency), as was probably originally intended.

For now the implementation seems to work, except that conversions for list items do not work for all types. We can probably leave that to a future release, as and are being pushed to another release as well.


Garret Wilson


Garret Wilson



Affects versions