users@jsr311.java.net

Re: 1.1 Change C006

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Mon, 23 Feb 2009 15:03:39 -0500

On Feb 23, 2009, at 10:55 AM, Michael Brackx wrote:
>
> Instead of requiring a static fromString method for converting
> parameters i would suggest the introduction of an extra extension
> point: the StringConverter provider.
>
> A StringConverter could do the conversion from(/to) a String to(/form)
> a parameter type. It could be annotated with @Provider and be
> registered like other providers.
>
> This functionality has been implemented in RESTEasy
> The StringConverter javadoc:
> http://www.jboss.org/file-access/default/members/resteasy/freezone/docs/1.0.2.GA/javadocs/org/jboss/resteasy/spi/StringConverter.html
> Documentation:
> http://www.jboss.org/file-access/default/members/resteasy/freezone/docs/1.0.2.GA/userguide/html/StringConverter.html
>
Nice.

Given that fromString is quite a common method it seems useful to add
it anyway but I agree that a more general-purpose string converter
provider would be a nice addition. Unfortunately we are now into the
final week of the MR when the EC votes on each line item and I'm
unable to add this now. Could you create an issue we can use to make
sure we revisit this for the next maintenance release.

Thanks,
Marc.


> Some advantages over a static fromString/valueOf method:
> - StringConverters can be used if the parameter type cannot be
> changed:
> -- types from third party libraries
> -- if code is not available
> -- if classes are final
> - sometimes static methods are not recommended, for example because
> they cannot be stubbed, or even not permitted because of code style
> - enum names can be restricted by code style (e.g. all uppercase),
> where an API might required lowercase "constants"
>
> Michael Brackx
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>

---
Marc Hadley <marc.hadley at sun.com>
Sun Microsystems.