Hello again,
I found where my problem is...
In Converter's specification converting from Map to target DTO or
JavaBeans there is no need to the source to provide all the keys. the
converter just ignore missing keys. But unfortunately, the same was not
allowed with Interfaces. I can't think one reason for that... :-
From spec:
Interfaces can provide methods for default values by providing a
single-argument method override
in addition to the no-parameter method matching the key name. If the
type of the default does not
match the target type it is converted first.
Default values are used when the key is not present in the map for the
method. If a key is present
with a null value, then null is taken as the value and converted to
the target type.
If no default is specified and a requested value is not present in the
map, a ConversionException is
thrown.
With such approach to use overridden method to set the default values it
is almost impossible to use an interfaces to deal with complex json with
optional attributes.
We are using interfaces to generate compile-time immutable structures
(classes and their builders) and using them everywhere. So reusing those
interfaces appeared to be the right choice in order to receive data from
Configurator's JSON complex structure and then pass the proxy object
created by Converter to our immutable class builder.
I'll need to think of another solution now, any ideas ?
best regards,
Cristiano