[morph-developer] TextConverter using null as destinationClass
Brought to you by:
orangeherbert,
sgarlatm
|
From: Matt B. <gud...@ya...> - 2007-04-20 13:36:13
|
I have noticed that TextConverter declares it is able to use null as a source and destination class, but it is actually not able to use null for a destination. And since lots of converters use a TextConverter to provide for free multiple destination types with the implementor only having to provide a String conversion, these TextConverter consumers inherit the problem. This leaves a few options: 1. Agree that in the common paradigm converters allow null sources but not destinations. Because of the NullConverter the majority of existing functionality would be preserved. The most unfortunate drawback of this approach is that converters which declare a single set of source-AND-destination types including null (e.g. TextConverter) would have to be adjusted to differ their listing of provided source/dest types. 2. Alter the default isTransformableImpl behavior in BaseTransformer (either here or in TransformerUtils) to disallow null destinationClass. Not sure I like this either. 3. Rework classes that declare null as a destination type to actually be able to return null. Most likely here it would make sense to check for null destinationType in BaseTransformer.convert()--I think we can agree that there is only one possible return value from a null conversion. I would probably choose this alternative, personally. In any event, we also need to determine what the expected behavior is of TextConverter when converting null to a text type. Is it empty, or is it "null"? Which is more likely to serve 99% of what users would want OOTB? WDYT? -Matt B __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |