Re: [picocontainer-dev] ConfigParameterTestCase / ConfigParameter
Paul Hammant <[email protected]>
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Message-ID | <[email protected]> |
Jörg,
>
> [snip]
>
> so we would have instead:
>
> private static final Map<Class, ParameterFactory>
> stringConverters = new HashMap<Class, ParameterFactory>();
> static {
> stringConverters.put(Integer.class,
> new ValueOfParameterFactory<Integer>();
> stringConverters.put(Double.class,
> new ValueOfParameterFactory<Double>();
> stringConverters.put(Boolean.class,
> new ValueOfParameterFactory<Boolean>();
> stringConverters.put(Long.class,
> new ValueOfParameterFactory<Long>();
> stringConverters.put(File.class,
> new StringConstructorParameterFactory<File>();
> ...
> }
>
> We might find better names for the classes though. We may collect
> them in an
> own package.
I appreciate we can reduce the (inner) class count with this design,
but we'd be relying on reflection, as Sun did not see fit to have an
interface for this boiler-plate stuff (valueOf).
I'm not sure its worth the cost.
>
>> I think for now, a fixed list of conversions is fine - going up to
>> the set that XStream caters for.
>
> You can only use the SingleValueConverters anyway and with the
> generified
> versions from my last posting, you can handle quite a lot.
>
Explain a bit more? As I see it ....
class ValueOfParameterFactory<T> extends APF<T> {
T fromString(String s) {
return T.valueOf(s);
}
}
.... can't work because valueOf is not part of an interface/
abstraction that safe for generics. You'd have to do that fragment
with reflection ... making it uglier and slower.
- Paul
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email