[Simple-support] Using DefaultType=PROPERTY by default
Brought to you by:
niallg
|
From: Roman P. <rom...@gm...> - 2014-02-10 11:32:38
|
Hello. By default, simplexml uses fields to map object data to/from XML. This can be overriden by using @Default(DefaultType.PROPERTY) on each class. In our project, we need to use the property-centric approach, and it's a bit uncomfortable to annotate every single model class, as this is error-prone: someone can forget to annotate some class, a field-centric strategy will be used, so some getter/setter logic will not be called leading to tricky errors. simplexml actually contains a 'meta-default': in org.simpleframework.xml.core.Support class, DefaultType.FIELD is hard-coded as a default for cases when no @Default annotation is specified (an 'override'). Support class is instantiated by Persister, so it seems to be pretty straight-forward to add a parameter (or other way to configure it) defining such a default to the Persister, which would in turn pass this setting via constructor to Support. My question is - is this plausible? Doesn't it break some big architecture rule? I can craft a patch implementing this approach. Best regards, Roman Puchkovskiy |