commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject Re: [BeanUtils] ConvertUtils.convert too restrictive?
Date Tue, 26 Aug 2003 22:01:15 GMT
hi scott

(you seem in a very argumentative mood. i'll try to avoid taking the bait.

On Tuesday, August 26, 2003, at 09:57 PM, Scott Howlett wrote:

> Why does this function:
>     ConvertUtils.convert(String value, Class type)
> require a String argument? All it does is dispatch to some Converter
> that can take any Object, so this restriction seems unnecessary. It
> causes callers to have to convert to string first which may sometimes
> not be desirable.

i suspect that the reason for this is that ConvertUtils was designed to 
handle string to object conversions (rather than object-to-object ones). 
when examined from this perspective, the signature is very reasonable.

> In particular this seems to cause problems with BeanUtils.setProperty().
> I asked the same question in a comment on this bug:
> but I haven't heard anything.

the beanutils bug lists have a very large backlog.

the issue boils down to the fact that ConvertUtils is design to perform 
string-to-object conversions rather than more general object-to-object 
conversions. i'd say that the most satisfactory to solve both your problem 
and the more general issue would be to subclass PropertyUtilBean or add a 
pluggable strategy which would allow any compliant implementation to be 

> Oh - while I'm asking, why do Converter objects bother taking a type
> argument at all? None of the converters I looked at bother to use it -
> they just assume they're converting to the type they were registered
> for. If this usage is widespread, perhaps a new version without the type
> argument ought to be created and the existing one deprecated.

setting aside that this is not going to happen (due to backward 
compatibility issues), just because most people don't use a particular 
feature doesn't mean that it should be removed. i know that there are 
users who use this feature. whatever the faults that beanutils exhibits, 
thankfully the code isn't so bloated yet that we need to consider removing 
features used only by minorities.

- robert

View raw message