Re: [convert] Automatic conversion based on proxies

2013-08-15 Thread Jörg Schaible
Hi, Emmanuel Bourg wrote: Le 14/08/2013 17:39, Adrian Crum a écrit : Instead of int columnInt = record.getValueAsInt(1); the developer would use Integer columnInt = Util.convertTo(record.getValue(1), Integer.class); +1 for the static method, that would allow the use of a static

Re: [convert] Automatic conversion based on proxies

2013-08-15 Thread James Carman
I personally think we're over-thinking this thing. Keep it simple, folks: public interface ConverterF,T { T convert(F from); } You can auto-detect the F/T parameters when a Converter is registered. On Thu, Aug 15, 2013 at 4:42 AM, Jörg Schaible joerg.schai...@scalaris.com wrote: Hi,

Re: [convert] Automatic conversion based on proxies

2013-08-15 Thread Gary Gregory
Should the framework try to convert transitively? Gary On Aug 15, 2013, at 6:56, James Carman ja...@carmanconsulting.com wrote: I personally think we're over-thinking this thing. Keep it simple, folks: public interface ConverterF,T { T convert(F from); } You can auto-detect the F/T

Re: [convert] Automatic conversion based on proxies

2013-08-15 Thread James Carman
You mean if it has a converter from A - B and B - C and you ask for a conversion from A - C, it would figure it out? That's and interesting idea. I guess you'd need to make sure there is no loss of fidelity when doing the conversions. On Thu, Aug 15, 2013 at 8:00 AM, Gary Gregory

Re: [convert] Automatic conversion based on proxies

2013-08-15 Thread Gary Gregory
On Thu, Aug 15, 2013 at 9:09 AM, James Carman ja...@carmanconsulting.comwrote: You mean if it has a converter from A - B and B - C and you ask for a conversion from A - C, it would figure it out? That's and interesting idea. I guess you'd need to make sure there is no loss of fidelity when

Re: [convert] Automatic conversion based on proxies

2013-08-15 Thread James Carman
Perhaps you'd have a different method on the registry like this: ConverterF,T createConverterPath(ClassF fromType, ClassT toType); This way, you're specifically letting the registry know that you're okay with it filling in the blanks in between fromType and toType. On Thu, Aug 15, 2013 at 9:24

Re: [convert] Automatic conversion based on proxies

2013-08-15 Thread Oliver Heger
Am 15.08.2013 15:33, schrieb James Carman: Perhaps you'd have a different method on the registry like this: ConverterF,T createConverterPath(ClassF fromType, ClassT toType); This way, you're specifically letting the registry know that you're okay with it filling in the blanks in between

Re: [convert] Automatic conversion based on proxies

2013-08-15 Thread James Carman
I'm okay with layers too. You need to open up the API for querying so that upper layers can traverse the graph. On Thursday, August 15, 2013, Oliver Heger wrote: Am 15.08.2013 15:33, schrieb James Carman: Perhaps you'd have a different method on the registry like this: ConverterF,T

Re: [convert] Automatic conversion based on proxies

2013-08-14 Thread Gary Gregory
On Tue, Aug 13, 2013 at 4:01 PM, Oliver Heger oliver.he...@oliver-heger.dewrote: Hi all, recently, there was a discussion about extending the [csv] interface to provide data conversions to different types. If such a use case is to be supported, what would be the best approach to integrate a

Re: [convert] Automatic conversion based on proxies

2013-08-14 Thread Adrian Crum
I don't think CSV needs anything special to accommodate type conversion. The pattern I tried to introduce in the Commons Convert Getting Started section is one that works in any part of an application where conversion might be needed. So, instead of hard-coding conversions, the developer

Re: [convert] Automatic conversion based on proxies

2013-08-14 Thread Oliver Heger
Am 14.08.2013 16:54, schrieb Gary Gregory: On Tue, Aug 13, 2013 at 4:01 PM, Oliver Heger oliver.he...@oliver-heger.dewrote: Hi all, recently, there was a discussion about extending the [csv] interface to provide data conversions to different types. If such a use case is to be supported,

Re: [convert] Automatic conversion based on proxies

2013-08-14 Thread Oliver Heger
Am 14.08.2013 17:39, schrieb Adrian Crum: I don't think CSV needs anything special to accommodate type conversion. The pattern I tried to introduce in the Commons Convert Getting Started section is one that works in any part of an application where conversion might be needed. So, instead of

Re: [convert] Automatic conversion based on proxies

2013-08-14 Thread Emmanuel Bourg
Le 14/08/2013 17:39, Adrian Crum a écrit : Instead of int columnInt = record.getValueAsInt(1); the developer would use Integer columnInt = Util.convertTo(record.getValue(1), Integer.class); +1 for the static method, that would allow the use of a static import and a very concise syntax

Re: [convert] Automatic conversion based on proxies

2013-08-14 Thread Paul Benedict
The only danger of static methods is that you can't override them. BeanUtils first suffered from this fate and they then made an instance version (BeanUtils2). Just said plainly, you can't customize well using factory classes/methods. On Wed, Aug 14, 2013 at 3:04 PM, Emmanuel Bourg

Re: [convert] Automatic conversion based on proxies

2013-08-14 Thread James Carman
On Wed, Aug 14, 2013 at 4:04 PM, Emmanuel Bourg ebo...@apache.org wrote: That being said, [convert] could offer several patterns to perform type conversion, and the use of proxies could be one of them. I know of a project that might be able to help you with those proxies, too! :)

[convert] Automatic conversion based on proxies

2013-08-13 Thread Oliver Heger
Hi all, recently, there was a discussion about extending the [csv] interface to provide data conversions to different types. If such a use case is to be supported, what would be the best approach to integrate a library like [convert]? Doing all required conversions manually would probably mean a