On 19 October 2011 11:55, Chris Bartlett <[email protected]> wrote: > BXMLSerializer could perhaps go one step further in the coercion phase > and attempt to find a single parameter constructor on the > 'destination' type which accepts the 'source' type? (I haven't fully > thought through the implications of this, so it might not work or be > desirable behaviour.) Then the multiple setters could be removed, and > the various constructors used instead.
(Just noting a few things that popped into my head as a result of this...) The type coercion is performed in the BeanAdapter.coerce(Object, Class) static method. http://pivot.apache.org/2.0/docs/api/org/apache/pivot/beans/BeanAdapter.html#coerce(java.lang.Object, java.lang.Class) http://svn.apache.org/repos/asf/pivot/trunk/core/src/org/apache/pivot/beans/BeanAdapter.java I suppose another option would be to create a trivial convert/coerce interface and accompanying registry to maintain the mappings. BeanAdapter.coerce() could query the registry and use a found converter instance, either instead of the built in coercion or if the built in one failed. A very simple kind of service provider interface might be a good fit. Just drop the converter implementations in a specific classpath location and BeanAdapter would take care of registering whatever it discovered when it is first instantiated. Chris
