You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Igor Vaynberg <ig...@gmail.com> on 2008/04/15 20:05:32 UTC
problem with converter generics
example below doesnt compile, so im not exactly sure how to override
generified getconverter() properly ... do we need to change our
generics decl somehow?
-igor
@Override
public <Z> IConverter<Z> getConverter(Class<Z> type)
{
if (Integer.class.isAssignableFrom(type))
{
return new IConverter<Integer>()
{
private static final long serialVersionUID = 1L;
public Integer convertToObject(String value, Locale locale)
{
return null;
}
public String convertToString(Integer value, Locale locale)
{
return null;
}
};
}
else
{
return super.getConverter(type);
}
}
Re: problem with converter generics
Posted by Bruno Borges <br...@gmail.com>.
I agree... :-)
So, let be <?> :-D
On Tue, Apr 15, 2008 at 5:04 PM, Igor Vaynberg <ig...@gmail.com>
wrote:
> that is actually a pro and not a con. we call getconverter() whle
> users implement getconverter(). so id rather its us (wicket devs) that
> have to cast
>
> -igor
>
>
> On Tue, Apr 15, 2008 at 12:42 PM, Bruno Borges <br...@gmail.com>
> wrote:
> > Yeah, but that way you have to cast outsite getConverter:
> >
> > IConverter<Integer> c = (IConverter<Integer>)
> getConverter(Integer.class);
> >
> > The way I propose, the casting control is inside.
> >
> > On Tue, Apr 15, 2008 at 4:39 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >
> >
> >
> > wrote:
> >
> > > if i have to do a hard cast there is very little advantage to <L>,
> > > might as well be public IConverter<?> getConverter(Class<?> clazz)
> > >
> > > -igor
> > >
> > >
> > > On Tue, Apr 15, 2008 at 12:25 PM, Bruno Borges <
> bruno.borges@gmail.com>
> > > wrote:
> > > > This is what you could do:
> > > >
> > > > import java.util.Locale;
> > > >
> > > > public class Test {
> > > > public <L> IConverter<L> getConverter(Class<L> type) {
> > > > return null;
> > > > }
> > > > }
> > > >
> > > > class InnerTest extends Test {
> > > >
> > > > public <K> IConverter<K> getConverter(Class<K> type) {
> > > > if (Integer.class.isAssignableFrom(type)) {
> > > > return (IConverter<K>) new IConverter<Integer>() {
> > > >
> > > > public Integer convertToObject(String value, Locale
> locale)
> > > {
> > > > return null;
> > > > }
> > > > public String convertToString(Integer value, Locale
> locale)
> > > {
> > > > return null;
> > > > }
> > > > };
> > > > } else {
> > > > return super.getConverter(type);
> > > > }
> > > > }
> > > >
> > > > public void foo() {
> > > > IConverter<Integer> converter = getConverter(Integer.class);
> > > > }
> > > > }
> > > >
> > > > interface IConverter<X> {
> > > > public X convertToObject(String value, Locale locale);
> > > > public String convertToString(Integer value, Locale locale);
> > > > }
> > > >
> > > > But, you are obligated to use a hard cast inside of getConverter
> either
> > > way.
> > > >
> > > > Regards
> > > >
> > > > On Tue, Apr 15, 2008 at 4:04 PM, Igor Vaynberg <
> igor.vaynberg@gmail.com
> > > >
> > > >
> > > >
> > > > wrote:
> > > >
> > > > > Type mismatch: cannot convert from new IConverter<Integer>(){}
> to
> > > > > IConverter<Z>
> > > > >
> > > > > i can hard cast to IConverter<Z> myself, but then there is very
> > > little
> > > > > point to having it generified
> > > > >
> > > > > -igor
> > > > >
> > > > >
> > > > > On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <
> > > bruno.borges@gmail.com>
> > > > > wrote:
> > > > > > What is the compile error message?
> > > > > >
> > > > > > On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <
> > > igor.vaynberg@gmail.com
> > > > > >
> > > > > >
> > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > maybe just IConverter<?> getConverter(Class<?> cl)
> > > > > > >
> > > > > > > -igor
> > > > > > >
> > > > > > >
> > > > > > > On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
> > > > > igor.vaynberg@gmail.com>
> > > > > > > wrote:
> > > > > > > > example below doesnt compile, so im not exactly sure how
> to
> > > > > override
> > > > > > > > generified getconverter() properly ... do we need to
> change
> > > our
> > > > > > > > generics decl somehow?
> > > > > > > >
> > > > > > > > -igor
> > > > > > > >
> > > > > > > > @Override
> > > > > > > > public <Z> IConverter<Z> getConverter(Class<Z>
> type)
> > > > > > > > {
> > > > > > > > if (Integer.class.isAssignableFrom(type))
> > > > > > > > {
> > > > > > > > return new IConverter<Integer>()
> > > > > > > > {
> > > > > > > > private static final long
> > > > > > > serialVersionUID = 1L;
> > > > > > > >
> > > > > > > > public Integer
> > > > > convertToObject(String
> > > > > > > value, Locale locale)
> > > > > > > > {
> > > > > > > > return null;
> > > > > > > > }
> > > > > > > >
> > > > > > > > public String
> > > > > convertToString(Integer
> > > > > > > value, Locale locale)
> > > > > > > > {
> > > > > > > > return null;
> > > > > > > > }
> > > > > > > >
> > > > > > > > };
> > > > > > > > }
> > > > > > > > else
> > > > > > > > {
> > > > > > > > return super.getConverter(type);
> > > > > > > > }
> > > > > > > > }
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Bruno Borges
> > > > > > blog.brunoborges.com.br
> > > > > > +55 1185657739
> > > > > >
> > > > > > "The glory of great men should always be
> > > > > > measured by the means they have used to
> > > > > > acquire it."
> > > > > > - Francois de La Rochefoucauld
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > >
> > > > Bruno Borges
> > > > blog.brunoborges.com.br
> > > > +55 1185657739
> > > >
> > > > "The glory of great men should always be
> > > > measured by the means they have used to
> > > > acquire it."
> > > > - Francois de La Rochefoucauld
> > > >
> > >
> >
> >
> >
> > --
> >
> >
> > Bruno Borges
> > blog.brunoborges.com.br
> > +55 1185657739
> >
> > "The glory of great men should always be
> > measured by the means they have used to
> > acquire it."
> > - Francois de La Rochefoucauld
> >
>
--
Bruno Borges
blog.brunoborges.com.br
+55 1185657739
"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld
Re: problem with converter generics
Posted by Peter Ertl <pe...@gmx.net>.
*lol*
Am 15.04.2008 um 22:34 schrieb Igor Vaynberg:
> what do you have against butts? :)
>
> -igor
>
>
> On Tue, Apr 15, 2008 at 1:27 PM, Peter Ertl <pe...@gmx.net>
> wrote:
>> +1 for "public IConverter<?> getConverter(Class<?> clazz)"
>>
>> having to cast the IConverter
>>
>>
>>> return (IConverter<K>) new IConverter<Integer>() {
>>
>> looks butt-ugly to me :-(
>>
>>
>> Am 15.04.2008 um 22:04 schrieb Igor Vaynberg:
>>
>>
>>
>>
>>> that is actually a pro and not a con. we call getconverter() whle
>>> users implement getconverter(). so id rather its us (wicket devs)
>>> that
>>> have to cast
>>>
>>> -igor
>>>
>>>
>>> On Tue, Apr 15, 2008 at 12:42 PM, Bruno Borges <bruno.borges@gmail.com
>>> >
>> wrote:
>>>
>>>> Yeah, but that way you have to cast outsite getConverter:
>>>>
>>>> IConverter<Integer> c = (IConverter<Integer>)
>> getConverter(Integer.class);
>>>>
>>>> The way I propose, the casting control is inside.
>>>>
>>>> On Tue, Apr 15, 2008 at 4:39 PM, Igor Vaynberg <igor.vaynberg@gmail.com
>>>> >
>>>>
>>>>
>>>> wrote:
>>>>
>>>>
>>>>> if i have to do a hard cast there is very little advantage to <L>,
>>>>> might as well be public IConverter<?> getConverter(Class<?> clazz)
>>>>>
>>>>> -igor
>>>>>
>>>>>
>>>>> On Tue, Apr 15, 2008 at 12:25 PM, Bruno Borges
>> <br...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> This is what you could do:
>>>>>>
>>>>>> import java.util.Locale;
>>>>>>
>>>>>> public class Test {
>>>>>> public <L> IConverter<L> getConverter(Class<L> type) {
>>>>>> return null;
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> class InnerTest extends Test {
>>>>>>
>>>>>> public <K> IConverter<K> getConverter(Class<K> type) {
>>>>>> if (Integer.class.isAssignableFrom(type)) {
>>>>>> return (IConverter<K>) new IConverter<Integer>() {
>>>>>>
>>>>>> public Integer convertToObject(String value, Locale
>> locale)
>>>>>>
>>>>> {
>>>>>
>>>>>> return null;
>>>>>> }
>>>>>> public String convertToString(Integer value, Locale
>> locale)
>>>>>>
>>>>> {
>>>>>
>>>>>> return null;
>>>>>> }
>>>>>> };
>>>>>> } else {
>>>>>> return super.getConverter(type);
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> public void foo() {
>>>>>> IConverter<Integer> converter = getConverter(Integer.class);
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> interface IConverter<X> {
>>>>>> public X convertToObject(String value, Locale locale);
>>>>>> public String convertToString(Integer value, Locale locale);
>>>>>> }
>>>>>>
>>>>>> But, you are obligated to use a hard cast inside of getConverter
>> either
>>>>>>
>>>>> way.
>>>>>
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>> On Tue, Apr 15, 2008 at 4:04 PM, Igor Vaynberg
>> <igor.vaynberg@gmail.com
>>>>>>
>>>>>>
>>>>>>
>>>>>> wrote:
>>>>>>
>>>>>>
>>>>>>> Type mismatch: cannot convert from new IConverter<Integer>(){}
>>>>>>> to
>>>>>>> IConverter<Z>
>>>>>>>
>>>>>>> i can hard cast to IConverter<Z> myself, but then there is very
>>>>>>>
>>>>>>
>>>>> little
>>>>>
>>>>>>
>>>>>>> point to having it generified
>>>>>>>
>>>>>>> -igor
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <
>>>>>>>
>>>>>>
>>>>> bruno.borges@gmail.com>
>>>>>
>>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> What is the compile error message?
>>>>>>>>
>>>>>>>> On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <
>>>>>>>>
>>>>>>>
>>>>>>
>>>>> igor.vaynberg@gmail.com
>>>>>
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> maybe just IConverter<?> getConverter(Class<?> cl)
>>>>>>>>>
>>>>>>>>> -igor
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
>>>>>>>>>
>>>>>>>>
>>>>>>> igor.vaynberg@gmail.com>
>>>>>>>
>>>>>>>>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> example below doesnt compile, so im not exactly sure how to
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>> override
>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>> generified getconverter() properly ... do we need to change
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>> our
>>>>>
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>> generics decl somehow?
>>>>>>>>>>
>>>>>>>>>> -igor
>>>>>>>>>>
>>>>>>>>>> @Override
>>>>>>>>>> public <Z> IConverter<Z> getConverter(Class<Z> type)
>>>>>>>>>> {
>>>>>>>>>> if (Integer.class.isAssignableFrom(type))
>>>>>>>>>> {
>>>>>>>>>> return new IConverter<Integer>()
>>>>>>>>>> {
>>>>>>>>>> private static final long
>>>>>>>>>>
>>>>>>>>> serialVersionUID = 1L;
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> public Integer
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>> convertToObject(String
>>>>>>>
>>>>>>>>
>>>>>>>>> value, Locale locale)
>>>>>>>>>
>>>>>>>>>> {
>>>>>>>>>> return null;
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> public String
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>> convertToString(Integer
>>>>>>>
>>>>>>>>
>>>>>>>>> value, Locale locale)
>>>>>>>>>
>>>>>>>>>> {
>>>>>>>>>> return null;
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> };
>>>>>>>>>> }
>>>>>>>>>> else
>>>>>>>>>> {
>>>>>>>>>> return super.getConverter(type);
>>>>>>>>>> }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Bruno Borges
>>>>>>>> blog.brunoborges.com.br
>>>>>>>> +55 1185657739
>>>>>>>>
>>>>>>>> "The glory of great men should always be
>>>>>>>> measured by the means they have used to
>>>>>>>> acquire it."
>>>>>>>> - Francois de La Rochefoucauld
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>>
>>>>>> Bruno Borges
>>>>>> blog.brunoborges.com.br
>>>>>> +55 1185657739
>>>>>>
>>>>>> "The glory of great men should always be
>>>>>> measured by the means they have used to
>>>>>> acquire it."
>>>>>> - Francois de La Rochefoucauld
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>>
>>>> Bruno Borges
>>>> blog.brunoborges.com.br
>>>> +55 1185657739
>>>>
>>>> "The glory of great men should always be
>>>> measured by the means they have used to
>>>> acquire it."
>>>> - Francois de La Rochefoucauld
>>>>
>>>>
>>>
>>
>>
Re: problem with converter generics
Posted by Igor Vaynberg <ig...@gmail.com>.
what do you have against butts? :)
-igor
On Tue, Apr 15, 2008 at 1:27 PM, Peter Ertl <pe...@gmx.net> wrote:
> +1 for "public IConverter<?> getConverter(Class<?> clazz)"
>
> having to cast the IConverter
>
>
> > return (IConverter<K>) new IConverter<Integer>() {
>
> looks butt-ugly to me :-(
>
>
> Am 15.04.2008 um 22:04 schrieb Igor Vaynberg:
>
>
>
>
> > that is actually a pro and not a con. we call getconverter() whle
> > users implement getconverter(). so id rather its us (wicket devs) that
> > have to cast
> >
> > -igor
> >
> >
> > On Tue, Apr 15, 2008 at 12:42 PM, Bruno Borges <br...@gmail.com>
> wrote:
> >
> > > Yeah, but that way you have to cast outsite getConverter:
> > >
> > > IConverter<Integer> c = (IConverter<Integer>)
> getConverter(Integer.class);
> > >
> > > The way I propose, the casting control is inside.
> > >
> > > On Tue, Apr 15, 2008 at 4:39 PM, Igor Vaynberg <ig...@gmail.com>
> > >
> > >
> > > wrote:
> > >
> > >
> > > > if i have to do a hard cast there is very little advantage to <L>,
> > > > might as well be public IConverter<?> getConverter(Class<?> clazz)
> > > >
> > > > -igor
> > > >
> > > >
> > > > On Tue, Apr 15, 2008 at 12:25 PM, Bruno Borges
> <br...@gmail.com>
> > > > wrote:
> > > >
> > > > > This is what you could do:
> > > > >
> > > > > import java.util.Locale;
> > > > >
> > > > > public class Test {
> > > > > public <L> IConverter<L> getConverter(Class<L> type) {
> > > > > return null;
> > > > > }
> > > > > }
> > > > >
> > > > > class InnerTest extends Test {
> > > > >
> > > > > public <K> IConverter<K> getConverter(Class<K> type) {
> > > > > if (Integer.class.isAssignableFrom(type)) {
> > > > > return (IConverter<K>) new IConverter<Integer>() {
> > > > >
> > > > > public Integer convertToObject(String value, Locale
> locale)
> > > > >
> > > > {
> > > >
> > > > > return null;
> > > > > }
> > > > > public String convertToString(Integer value, Locale
> locale)
> > > > >
> > > > {
> > > >
> > > > > return null;
> > > > > }
> > > > > };
> > > > > } else {
> > > > > return super.getConverter(type);
> > > > > }
> > > > > }
> > > > >
> > > > > public void foo() {
> > > > > IConverter<Integer> converter = getConverter(Integer.class);
> > > > > }
> > > > > }
> > > > >
> > > > > interface IConverter<X> {
> > > > > public X convertToObject(String value, Locale locale);
> > > > > public String convertToString(Integer value, Locale locale);
> > > > > }
> > > > >
> > > > > But, you are obligated to use a hard cast inside of getConverter
> either
> > > > >
> > > > way.
> > > >
> > > > >
> > > > > Regards
> > > > >
> > > > > On Tue, Apr 15, 2008 at 4:04 PM, Igor Vaynberg
> <igor.vaynberg@gmail.com
> > > > >
> > > > >
> > > > >
> > > > > wrote:
> > > > >
> > > > >
> > > > > > Type mismatch: cannot convert from new IConverter<Integer>(){} to
> > > > > > IConverter<Z>
> > > > > >
> > > > > > i can hard cast to IConverter<Z> myself, but then there is very
> > > > > >
> > > > >
> > > > little
> > > >
> > > > >
> > > > > > point to having it generified
> > > > > >
> > > > > > -igor
> > > > > >
> > > > > >
> > > > > > On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <
> > > > > >
> > > > >
> > > > bruno.borges@gmail.com>
> > > >
> > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > What is the compile error message?
> > > > > > >
> > > > > > > On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <
> > > > > > >
> > > > > >
> > > > >
> > > > igor.vaynberg@gmail.com
> > > >
> > > > >
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > >
> > > > > > > > maybe just IConverter<?> getConverter(Class<?> cl)
> > > > > > > >
> > > > > > > > -igor
> > > > > > > >
> > > > > > > >
> > > > > > > > On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
> > > > > > > >
> > > > > > >
> > > > > > igor.vaynberg@gmail.com>
> > > > > >
> > > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > example below doesnt compile, so im not exactly sure how to
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > override
> > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > > generified getconverter() properly ... do we need to change
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > our
> > > >
> > > > >
> > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > > generics decl somehow?
> > > > > > > > >
> > > > > > > > > -igor
> > > > > > > > >
> > > > > > > > > @Override
> > > > > > > > > public <Z> IConverter<Z> getConverter(Class<Z> type)
> > > > > > > > > {
> > > > > > > > > if (Integer.class.isAssignableFrom(type))
> > > > > > > > > {
> > > > > > > > > return new IConverter<Integer>()
> > > > > > > > > {
> > > > > > > > > private static final long
> > > > > > > > >
> > > > > > > > serialVersionUID = 1L;
> > > > > > > >
> > > > > > > > >
> > > > > > > > > public Integer
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > convertToObject(String
> > > > > >
> > > > > > >
> > > > > > > > value, Locale locale)
> > > > > > > >
> > > > > > > > > {
> > > > > > > > > return null;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > public String
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > convertToString(Integer
> > > > > >
> > > > > > >
> > > > > > > > value, Locale locale)
> > > > > > > >
> > > > > > > > > {
> > > > > > > > > return null;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > };
> > > > > > > > > }
> > > > > > > > > else
> > > > > > > > > {
> > > > > > > > > return super.getConverter(type);
> > > > > > > > > }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Bruno Borges
> > > > > > > blog.brunoborges.com.br
> > > > > > > +55 1185657739
> > > > > > >
> > > > > > > "The glory of great men should always be
> > > > > > > measured by the means they have used to
> > > > > > > acquire it."
> > > > > > > - Francois de La Rochefoucauld
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > >
> > > > >
> > > > > Bruno Borges
> > > > > blog.brunoborges.com.br
> > > > > +55 1185657739
> > > > >
> > > > > "The glory of great men should always be
> > > > > measured by the means they have used to
> > > > > acquire it."
> > > > > - Francois de La Rochefoucauld
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > >
> > >
> > > Bruno Borges
> > > blog.brunoborges.com.br
> > > +55 1185657739
> > >
> > > "The glory of great men should always be
> > > measured by the means they have used to
> > > acquire it."
> > > - Francois de La Rochefoucauld
> > >
> > >
> >
>
>
Re: problem with converter generics
Posted by Peter Ertl <pe...@gmx.net>.
+1 for "public IConverter<?> getConverter(Class<?> clazz)"
having to cast the IConverter
> return (IConverter<K>) new IConverter<Integer>() {
looks butt-ugly to me :-(
Am 15.04.2008 um 22:04 schrieb Igor Vaynberg:
> that is actually a pro and not a con. we call getconverter() whle
> users implement getconverter(). so id rather its us (wicket devs) that
> have to cast
>
> -igor
>
>
> On Tue, Apr 15, 2008 at 12:42 PM, Bruno Borges
> <br...@gmail.com> wrote:
>> Yeah, but that way you have to cast outsite getConverter:
>>
>> IConverter<Integer> c = (IConverter<Integer>)
>> getConverter(Integer.class);
>>
>> The way I propose, the casting control is inside.
>>
>> On Tue, Apr 15, 2008 at 4:39 PM, Igor Vaynberg <igor.vaynberg@gmail.com
>> >
>>
>>
>> wrote:
>>
>>> if i have to do a hard cast there is very little advantage to <L>,
>>> might as well be public IConverter<?> getConverter(Class<?> clazz)
>>>
>>> -igor
>>>
>>>
>>> On Tue, Apr 15, 2008 at 12:25 PM, Bruno Borges <bruno.borges@gmail.com
>>> >
>>> wrote:
>>>> This is what you could do:
>>>>
>>>> import java.util.Locale;
>>>>
>>>> public class Test {
>>>> public <L> IConverter<L> getConverter(Class<L> type) {
>>>> return null;
>>>> }
>>>> }
>>>>
>>>> class InnerTest extends Test {
>>>>
>>>> public <K> IConverter<K> getConverter(Class<K> type) {
>>>> if (Integer.class.isAssignableFrom(type)) {
>>>> return (IConverter<K>) new IConverter<Integer>() {
>>>>
>>>> public Integer convertToObject(String value, Locale
>>>> locale)
>>> {
>>>> return null;
>>>> }
>>>> public String convertToString(Integer value, Locale
>>>> locale)
>>> {
>>>> return null;
>>>> }
>>>> };
>>>> } else {
>>>> return super.getConverter(type);
>>>> }
>>>> }
>>>>
>>>> public void foo() {
>>>> IConverter<Integer> converter = getConverter(Integer.class);
>>>> }
>>>> }
>>>>
>>>> interface IConverter<X> {
>>>> public X convertToObject(String value, Locale locale);
>>>> public String convertToString(Integer value, Locale locale);
>>>> }
>>>>
>>>> But, you are obligated to use a hard cast inside of getConverter
>>>> either
>>> way.
>>>>
>>>> Regards
>>>>
>>>> On Tue, Apr 15, 2008 at 4:04 PM, Igor Vaynberg <igor.vaynberg@gmail.com
>>>>
>>>>
>>>>
>>>> wrote:
>>>>
>>>>> Type mismatch: cannot convert from new IConverter<Integer>(){} to
>>>>> IConverter<Z>
>>>>>
>>>>> i can hard cast to IConverter<Z> myself, but then there is very
>>> little
>>>>> point to having it generified
>>>>>
>>>>> -igor
>>>>>
>>>>>
>>>>> On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <
>>> bruno.borges@gmail.com>
>>>>> wrote:
>>>>>> What is the compile error message?
>>>>>>
>>>>>> On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <
>>> igor.vaynberg@gmail.com
>>>>>>
>>>>>>
>>>>>>
>>>>>> wrote:
>>>>>>
>>>>>>> maybe just IConverter<?> getConverter(Class<?> cl)
>>>>>>>
>>>>>>> -igor
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
>>>>> igor.vaynberg@gmail.com>
>>>>>>> wrote:
>>>>>>>> example below doesnt compile, so im not exactly sure how to
>>>>> override
>>>>>>>> generified getconverter() properly ... do we need to change
>>> our
>>>>>>>> generics decl somehow?
>>>>>>>>
>>>>>>>> -igor
>>>>>>>>
>>>>>>>> @Override
>>>>>>>> public <Z> IConverter<Z> getConverter(Class<Z> type)
>>>>>>>> {
>>>>>>>> if (Integer.class.isAssignableFrom(type))
>>>>>>>> {
>>>>>>>> return new IConverter<Integer>()
>>>>>>>> {
>>>>>>>> private static final long
>>>>>>> serialVersionUID = 1L;
>>>>>>>>
>>>>>>>> public Integer
>>>>> convertToObject(String
>>>>>>> value, Locale locale)
>>>>>>>> {
>>>>>>>> return null;
>>>>>>>> }
>>>>>>>>
>>>>>>>> public String
>>>>> convertToString(Integer
>>>>>>> value, Locale locale)
>>>>>>>> {
>>>>>>>> return null;
>>>>>>>> }
>>>>>>>>
>>>>>>>> };
>>>>>>>> }
>>>>>>>> else
>>>>>>>> {
>>>>>>>> return super.getConverter(type);
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Bruno Borges
>>>>>> blog.brunoborges.com.br
>>>>>> +55 1185657739
>>>>>>
>>>>>> "The glory of great men should always be
>>>>>> measured by the means they have used to
>>>>>> acquire it."
>>>>>> - Francois de La Rochefoucauld
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>>
>>>> Bruno Borges
>>>> blog.brunoborges.com.br
>>>> +55 1185657739
>>>>
>>>> "The glory of great men should always be
>>>> measured by the means they have used to
>>>> acquire it."
>>>> - Francois de La Rochefoucauld
>>>>
>>>
>>
>>
>>
>> --
>>
>>
>> Bruno Borges
>> blog.brunoborges.com.br
>> +55 1185657739
>>
>> "The glory of great men should always be
>> measured by the means they have used to
>> acquire it."
>> - Francois de La Rochefoucauld
>>
Re: problem with converter generics
Posted by Igor Vaynberg <ig...@gmail.com>.
that is actually a pro and not a con. we call getconverter() whle
users implement getconverter(). so id rather its us (wicket devs) that
have to cast
-igor
On Tue, Apr 15, 2008 at 12:42 PM, Bruno Borges <br...@gmail.com> wrote:
> Yeah, but that way you have to cast outsite getConverter:
>
> IConverter<Integer> c = (IConverter<Integer>) getConverter(Integer.class);
>
> The way I propose, the casting control is inside.
>
> On Tue, Apr 15, 2008 at 4:39 PM, Igor Vaynberg <ig...@gmail.com>
>
>
> wrote:
>
> > if i have to do a hard cast there is very little advantage to <L>,
> > might as well be public IConverter<?> getConverter(Class<?> clazz)
> >
> > -igor
> >
> >
> > On Tue, Apr 15, 2008 at 12:25 PM, Bruno Borges <br...@gmail.com>
> > wrote:
> > > This is what you could do:
> > >
> > > import java.util.Locale;
> > >
> > > public class Test {
> > > public <L> IConverter<L> getConverter(Class<L> type) {
> > > return null;
> > > }
> > > }
> > >
> > > class InnerTest extends Test {
> > >
> > > public <K> IConverter<K> getConverter(Class<K> type) {
> > > if (Integer.class.isAssignableFrom(type)) {
> > > return (IConverter<K>) new IConverter<Integer>() {
> > >
> > > public Integer convertToObject(String value, Locale locale)
> > {
> > > return null;
> > > }
> > > public String convertToString(Integer value, Locale locale)
> > {
> > > return null;
> > > }
> > > };
> > > } else {
> > > return super.getConverter(type);
> > > }
> > > }
> > >
> > > public void foo() {
> > > IConverter<Integer> converter = getConverter(Integer.class);
> > > }
> > > }
> > >
> > > interface IConverter<X> {
> > > public X convertToObject(String value, Locale locale);
> > > public String convertToString(Integer value, Locale locale);
> > > }
> > >
> > > But, you are obligated to use a hard cast inside of getConverter either
> > way.
> > >
> > > Regards
> > >
> > > On Tue, Apr 15, 2008 at 4:04 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> > >
> > >
> > >
> > > wrote:
> > >
> > > > Type mismatch: cannot convert from new IConverter<Integer>(){} to
> > > > IConverter<Z>
> > > >
> > > > i can hard cast to IConverter<Z> myself, but then there is very
> > little
> > > > point to having it generified
> > > >
> > > > -igor
> > > >
> > > >
> > > > On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <
> > bruno.borges@gmail.com>
> > > > wrote:
> > > > > What is the compile error message?
> > > > >
> > > > > On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <
> > igor.vaynberg@gmail.com
> > > > >
> > > > >
> > > > >
> > > > > wrote:
> > > > >
> > > > > > maybe just IConverter<?> getConverter(Class<?> cl)
> > > > > >
> > > > > > -igor
> > > > > >
> > > > > >
> > > > > > On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
> > > > igor.vaynberg@gmail.com>
> > > > > > wrote:
> > > > > > > example below doesnt compile, so im not exactly sure how to
> > > > override
> > > > > > > generified getconverter() properly ... do we need to change
> > our
> > > > > > > generics decl somehow?
> > > > > > >
> > > > > > > -igor
> > > > > > >
> > > > > > > @Override
> > > > > > > public <Z> IConverter<Z> getConverter(Class<Z> type)
> > > > > > > {
> > > > > > > if (Integer.class.isAssignableFrom(type))
> > > > > > > {
> > > > > > > return new IConverter<Integer>()
> > > > > > > {
> > > > > > > private static final long
> > > > > > serialVersionUID = 1L;
> > > > > > >
> > > > > > > public Integer
> > > > convertToObject(String
> > > > > > value, Locale locale)
> > > > > > > {
> > > > > > > return null;
> > > > > > > }
> > > > > > >
> > > > > > > public String
> > > > convertToString(Integer
> > > > > > value, Locale locale)
> > > > > > > {
> > > > > > > return null;
> > > > > > > }
> > > > > > >
> > > > > > > };
> > > > > > > }
> > > > > > > else
> > > > > > > {
> > > > > > > return super.getConverter(type);
> > > > > > > }
> > > > > > > }
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Bruno Borges
> > > > > blog.brunoborges.com.br
> > > > > +55 1185657739
> > > > >
> > > > > "The glory of great men should always be
> > > > > measured by the means they have used to
> > > > > acquire it."
> > > > > - Francois de La Rochefoucauld
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > >
> > >
> > > Bruno Borges
> > > blog.brunoborges.com.br
> > > +55 1185657739
> > >
> > > "The glory of great men should always be
> > > measured by the means they have used to
> > > acquire it."
> > > - Francois de La Rochefoucauld
> > >
> >
>
>
>
> --
>
>
> Bruno Borges
> blog.brunoborges.com.br
> +55 1185657739
>
> "The glory of great men should always be
> measured by the means they have used to
> acquire it."
> - Francois de La Rochefoucauld
>
Re: problem with converter generics
Posted by Bruno Borges <br...@gmail.com>.
Yeah, but that way you have to cast outsite getConverter:
IConverter<Integer> c = (IConverter<Integer>) getConverter(Integer.class);
The way I propose, the casting control is inside.
On Tue, Apr 15, 2008 at 4:39 PM, Igor Vaynberg <ig...@gmail.com>
wrote:
> if i have to do a hard cast there is very little advantage to <L>,
> might as well be public IConverter<?> getConverter(Class<?> clazz)
>
> -igor
>
>
> On Tue, Apr 15, 2008 at 12:25 PM, Bruno Borges <br...@gmail.com>
> wrote:
> > This is what you could do:
> >
> > import java.util.Locale;
> >
> > public class Test {
> > public <L> IConverter<L> getConverter(Class<L> type) {
> > return null;
> > }
> > }
> >
> > class InnerTest extends Test {
> >
> > public <K> IConverter<K> getConverter(Class<K> type) {
> > if (Integer.class.isAssignableFrom(type)) {
> > return (IConverter<K>) new IConverter<Integer>() {
> >
> > public Integer convertToObject(String value, Locale locale)
> {
> > return null;
> > }
> > public String convertToString(Integer value, Locale locale)
> {
> > return null;
> > }
> > };
> > } else {
> > return super.getConverter(type);
> > }
> > }
> >
> > public void foo() {
> > IConverter<Integer> converter = getConverter(Integer.class);
> > }
> > }
> >
> > interface IConverter<X> {
> > public X convertToObject(String value, Locale locale);
> > public String convertToString(Integer value, Locale locale);
> > }
> >
> > But, you are obligated to use a hard cast inside of getConverter either
> way.
> >
> > Regards
> >
> > On Tue, Apr 15, 2008 at 4:04 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >
> >
> >
> > wrote:
> >
> > > Type mismatch: cannot convert from new IConverter<Integer>(){} to
> > > IConverter<Z>
> > >
> > > i can hard cast to IConverter<Z> myself, but then there is very
> little
> > > point to having it generified
> > >
> > > -igor
> > >
> > >
> > > On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <
> bruno.borges@gmail.com>
> > > wrote:
> > > > What is the compile error message?
> > > >
> > > > On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <
> igor.vaynberg@gmail.com
> > > >
> > > >
> > > >
> > > > wrote:
> > > >
> > > > > maybe just IConverter<?> getConverter(Class<?> cl)
> > > > >
> > > > > -igor
> > > > >
> > > > >
> > > > > On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
> > > igor.vaynberg@gmail.com>
> > > > > wrote:
> > > > > > example below doesnt compile, so im not exactly sure how to
> > > override
> > > > > > generified getconverter() properly ... do we need to change
> our
> > > > > > generics decl somehow?
> > > > > >
> > > > > > -igor
> > > > > >
> > > > > > @Override
> > > > > > public <Z> IConverter<Z> getConverter(Class<Z> type)
> > > > > > {
> > > > > > if (Integer.class.isAssignableFrom(type))
> > > > > > {
> > > > > > return new IConverter<Integer>()
> > > > > > {
> > > > > > private static final long
> > > > > serialVersionUID = 1L;
> > > > > >
> > > > > > public Integer
> > > convertToObject(String
> > > > > value, Locale locale)
> > > > > > {
> > > > > > return null;
> > > > > > }
> > > > > >
> > > > > > public String
> > > convertToString(Integer
> > > > > value, Locale locale)
> > > > > > {
> > > > > > return null;
> > > > > > }
> > > > > >
> > > > > > };
> > > > > > }
> > > > > > else
> > > > > > {
> > > > > > return super.getConverter(type);
> > > > > > }
> > > > > > }
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Bruno Borges
> > > > blog.brunoborges.com.br
> > > > +55 1185657739
> > > >
> > > > "The glory of great men should always be
> > > > measured by the means they have used to
> > > > acquire it."
> > > > - Francois de La Rochefoucauld
> > > >
> > >
> >
> >
> >
> > --
> >
> >
> > Bruno Borges
> > blog.brunoborges.com.br
> > +55 1185657739
> >
> > "The glory of great men should always be
> > measured by the means they have used to
> > acquire it."
> > - Francois de La Rochefoucauld
> >
>
--
Bruno Borges
blog.brunoborges.com.br
+55 1185657739
"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld
Re: problem with converter generics
Posted by Igor Vaynberg <ig...@gmail.com>.
if i have to do a hard cast there is very little advantage to <L>,
might as well be public IConverter<?> getConverter(Class<?> clazz)
-igor
On Tue, Apr 15, 2008 at 12:25 PM, Bruno Borges <br...@gmail.com> wrote:
> This is what you could do:
>
> import java.util.Locale;
>
> public class Test {
> public <L> IConverter<L> getConverter(Class<L> type) {
> return null;
> }
> }
>
> class InnerTest extends Test {
>
> public <K> IConverter<K> getConverter(Class<K> type) {
> if (Integer.class.isAssignableFrom(type)) {
> return (IConverter<K>) new IConverter<Integer>() {
>
> public Integer convertToObject(String value, Locale locale) {
> return null;
> }
> public String convertToString(Integer value, Locale locale) {
> return null;
> }
> };
> } else {
> return super.getConverter(type);
> }
> }
>
> public void foo() {
> IConverter<Integer> converter = getConverter(Integer.class);
> }
> }
>
> interface IConverter<X> {
> public X convertToObject(String value, Locale locale);
> public String convertToString(Integer value, Locale locale);
> }
>
> But, you are obligated to use a hard cast inside of getConverter either way.
>
> Regards
>
> On Tue, Apr 15, 2008 at 4:04 PM, Igor Vaynberg <ig...@gmail.com>
>
>
> wrote:
>
> > Type mismatch: cannot convert from new IConverter<Integer>(){} to
> > IConverter<Z>
> >
> > i can hard cast to IConverter<Z> myself, but then there is very little
> > point to having it generified
> >
> > -igor
> >
> >
> > On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <br...@gmail.com>
> > wrote:
> > > What is the compile error message?
> > >
> > > On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> > >
> > >
> > >
> > > wrote:
> > >
> > > > maybe just IConverter<?> getConverter(Class<?> cl)
> > > >
> > > > -igor
> > > >
> > > >
> > > > On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
> > igor.vaynberg@gmail.com>
> > > > wrote:
> > > > > example below doesnt compile, so im not exactly sure how to
> > override
> > > > > generified getconverter() properly ... do we need to change our
> > > > > generics decl somehow?
> > > > >
> > > > > -igor
> > > > >
> > > > > @Override
> > > > > public <Z> IConverter<Z> getConverter(Class<Z> type)
> > > > > {
> > > > > if (Integer.class.isAssignableFrom(type))
> > > > > {
> > > > > return new IConverter<Integer>()
> > > > > {
> > > > > private static final long
> > > > serialVersionUID = 1L;
> > > > >
> > > > > public Integer
> > convertToObject(String
> > > > value, Locale locale)
> > > > > {
> > > > > return null;
> > > > > }
> > > > >
> > > > > public String
> > convertToString(Integer
> > > > value, Locale locale)
> > > > > {
> > > > > return null;
> > > > > }
> > > > >
> > > > > };
> > > > > }
> > > > > else
> > > > > {
> > > > > return super.getConverter(type);
> > > > > }
> > > > > }
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Bruno Borges
> > > blog.brunoborges.com.br
> > > +55 1185657739
> > >
> > > "The glory of great men should always be
> > > measured by the means they have used to
> > > acquire it."
> > > - Francois de La Rochefoucauld
> > >
> >
>
>
>
> --
>
>
> Bruno Borges
> blog.brunoborges.com.br
> +55 1185657739
>
> "The glory of great men should always be
> measured by the means they have used to
> acquire it."
> - Francois de La Rochefoucauld
>
Re: problem with converter generics
Posted by Bruno Borges <br...@gmail.com>.
This is also a good pattern IMHO:
public <K> IConverter<K> getConverter(Class<K> type) {
if (Integer.class.isAssignableFrom(type)) {
return new IntegerConverter<K>();
} else {
return super.getConverter(type);
}
}
class IntegerConverter<J> implements IConverter<J> {
@SuppressWarnings("unchecked")
public J convertToObject(String value, Locale locale) {
return (J) new Integer(value);
}
public String convertToString(Integer value, Locale locale) {
return null;
}
}
Except that IntegerConverter class must not be public (I prefer it as an
inner or anonymous class.)
regards
On Tue, Apr 15, 2008 at 4:25 PM, Bruno Borges <br...@gmail.com>
wrote:
> This is what you could do:
>
> import java.util.Locale;
>
> public class Test {
> public <L> IConverter<L> getConverter(Class<L> type) {
> return null;
> }
> }
>
> class InnerTest extends Test {
> public <K> IConverter<K> getConverter(Class<K> type) {
> if (Integer.class.isAssignableFrom(type)) {
> return (IConverter<K>) new IConverter<Integer>() {
> public Integer convertToObject(String value, Locale locale) {
> return null;
> }
> public String convertToString(Integer value, Locale locale) {
> return null;
> }
> };
> } else {
> return super.getConverter(type);
> }
> }
>
> public void foo() {
> IConverter<Integer> converter = getConverter(Integer.class);
> }
> }
>
> interface IConverter<X> {
> public X convertToObject(String value, Locale locale);
> public String convertToString(Integer value, Locale locale);
> }
>
> But, you are obligated to use a hard cast inside of getConverter either
> way.
>
> Regards
>
>
> On Tue, Apr 15, 2008 at 4:04 PM, Igor Vaynberg <ig...@gmail.com>
> wrote:
>
> > Type mismatch: cannot convert from new IConverter<Integer>(){} to
> > IConverter<Z>
> >
> > i can hard cast to IConverter<Z> myself, but then there is very little
> > point to having it generified
> >
> > -igor
> >
> >
> > On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <br...@gmail.com>
> > wrote:
> > > What is the compile error message?
> > >
> > > On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <
> > igor.vaynberg@gmail.com>
> > >
> > >
> > > wrote:
> > >
> > > > maybe just IConverter<?> getConverter(Class<?> cl)
> > > >
> > > > -igor
> > > >
> > > >
> > > > On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
> > igor.vaynberg@gmail.com>
> > > > wrote:
> > > > > example below doesnt compile, so im not exactly sure how to
> > override
> > > > > generified getconverter() properly ... do we need to change our
> > > > > generics decl somehow?
> > > > >
> > > > > -igor
> > > > >
> > > > > @Override
> > > > > public <Z> IConverter<Z> getConverter(Class<Z> type)
> > > > > {
> > > > > if (Integer.class.isAssignableFrom(type))
> > > > > {
> > > > > return new IConverter<Integer>()
> > > > > {
> > > > > private static final long
> > > > serialVersionUID = 1L;
> > > > >
> > > > > public Integer
> > convertToObject(String
> > > > value, Locale locale)
> > > > > {
> > > > > return null;
> > > > > }
> > > > >
> > > > > public String
> > convertToString(Integer
> > > > value, Locale locale)
> > > > > {
> > > > > return null;
> > > > > }
> > > > >
> > > > > };
> > > > > }
> > > > > else
> > > > > {
> > > > > return super.getConverter(type);
> > > > > }
> > > > > }
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Bruno Borges
> > > blog.brunoborges.com.br
> > > +55 1185657739
> > >
> > > "The glory of great men should always be
> > > measured by the means they have used to
> > > acquire it."
> > > - Francois de La Rochefoucauld
> > >
> >
>
>
>
> --
> Bruno Borges
> blog.brunoborges.com.br
> +55 1185657739
>
> "The glory of great men should always be
> measured by the means they have used to
> acquire it."
> - Francois de La Rochefoucauld
>
--
Bruno Borges
blog.brunoborges.com.br
+55 1185657739
"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld
Re: problem with converter generics
Posted by Bruno Borges <br...@gmail.com>.
This is what you could do:
import java.util.Locale;
public class Test {
public <L> IConverter<L> getConverter(Class<L> type) {
return null;
}
}
class InnerTest extends Test {
public <K> IConverter<K> getConverter(Class<K> type) {
if (Integer.class.isAssignableFrom(type)) {
return (IConverter<K>) new IConverter<Integer>() {
public Integer convertToObject(String value, Locale locale) {
return null;
}
public String convertToString(Integer value, Locale locale) {
return null;
}
};
} else {
return super.getConverter(type);
}
}
public void foo() {
IConverter<Integer> converter = getConverter(Integer.class);
}
}
interface IConverter<X> {
public X convertToObject(String value, Locale locale);
public String convertToString(Integer value, Locale locale);
}
But, you are obligated to use a hard cast inside of getConverter either way.
Regards
On Tue, Apr 15, 2008 at 4:04 PM, Igor Vaynberg <ig...@gmail.com>
wrote:
> Type mismatch: cannot convert from new IConverter<Integer>(){} to
> IConverter<Z>
>
> i can hard cast to IConverter<Z> myself, but then there is very little
> point to having it generified
>
> -igor
>
>
> On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <br...@gmail.com>
> wrote:
> > What is the compile error message?
> >
> > On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >
> >
> >
> > wrote:
> >
> > > maybe just IConverter<?> getConverter(Class<?> cl)
> > >
> > > -igor
> > >
> > >
> > > On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
> igor.vaynberg@gmail.com>
> > > wrote:
> > > > example below doesnt compile, so im not exactly sure how to
> override
> > > > generified getconverter() properly ... do we need to change our
> > > > generics decl somehow?
> > > >
> > > > -igor
> > > >
> > > > @Override
> > > > public <Z> IConverter<Z> getConverter(Class<Z> type)
> > > > {
> > > > if (Integer.class.isAssignableFrom(type))
> > > > {
> > > > return new IConverter<Integer>()
> > > > {
> > > > private static final long
> > > serialVersionUID = 1L;
> > > >
> > > > public Integer
> convertToObject(String
> > > value, Locale locale)
> > > > {
> > > > return null;
> > > > }
> > > >
> > > > public String
> convertToString(Integer
> > > value, Locale locale)
> > > > {
> > > > return null;
> > > > }
> > > >
> > > > };
> > > > }
> > > > else
> > > > {
> > > > return super.getConverter(type);
> > > > }
> > > > }
> > > >
> > >
> >
> >
> >
> > --
> > Bruno Borges
> > blog.brunoborges.com.br
> > +55 1185657739
> >
> > "The glory of great men should always be
> > measured by the means they have used to
> > acquire it."
> > - Francois de La Rochefoucauld
> >
>
--
Bruno Borges
blog.brunoborges.com.br
+55 1185657739
"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld
Re: problem with converter generics
Posted by Igor Vaynberg <ig...@gmail.com>.
Type mismatch: cannot convert from new IConverter<Integer>(){} to IConverter<Z>
i can hard cast to IConverter<Z> myself, but then there is very little
point to having it generified
-igor
On Tue, Apr 15, 2008 at 11:59 AM, Bruno Borges <br...@gmail.com> wrote:
> What is the compile error message?
>
> On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <ig...@gmail.com>
>
>
> wrote:
>
> > maybe just IConverter<?> getConverter(Class<?> cl)
> >
> > -igor
> >
> >
> > On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <ig...@gmail.com>
> > wrote:
> > > example below doesnt compile, so im not exactly sure how to override
> > > generified getconverter() properly ... do we need to change our
> > > generics decl somehow?
> > >
> > > -igor
> > >
> > > @Override
> > > public <Z> IConverter<Z> getConverter(Class<Z> type)
> > > {
> > > if (Integer.class.isAssignableFrom(type))
> > > {
> > > return new IConverter<Integer>()
> > > {
> > > private static final long
> > serialVersionUID = 1L;
> > >
> > > public Integer convertToObject(String
> > value, Locale locale)
> > > {
> > > return null;
> > > }
> > >
> > > public String convertToString(Integer
> > value, Locale locale)
> > > {
> > > return null;
> > > }
> > >
> > > };
> > > }
> > > else
> > > {
> > > return super.getConverter(type);
> > > }
> > > }
> > >
> >
>
>
>
> --
> Bruno Borges
> blog.brunoborges.com.br
> +55 1185657739
>
> "The glory of great men should always be
> measured by the means they have used to
> acquire it."
> - Francois de La Rochefoucauld
>
Re: problem with converter generics
Posted by Bruno Borges <br...@gmail.com>.
What is the compile error message?
On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <ig...@gmail.com>
wrote:
> maybe just IConverter<?> getConverter(Class<?> cl)
>
> -igor
>
>
> On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <ig...@gmail.com>
> wrote:
> > example below doesnt compile, so im not exactly sure how to override
> > generified getconverter() properly ... do we need to change our
> > generics decl somehow?
> >
> > -igor
> >
> > @Override
> > public <Z> IConverter<Z> getConverter(Class<Z> type)
> > {
> > if (Integer.class.isAssignableFrom(type))
> > {
> > return new IConverter<Integer>()
> > {
> > private static final long
> serialVersionUID = 1L;
> >
> > public Integer convertToObject(String
> value, Locale locale)
> > {
> > return null;
> > }
> >
> > public String convertToString(Integer
> value, Locale locale)
> > {
> > return null;
> > }
> >
> > };
> > }
> > else
> > {
> > return super.getConverter(type);
> > }
> > }
> >
>
--
Bruno Borges
blog.brunoborges.com.br
+55 1185657739
"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld
Re: problem with converter generics
Posted by Igor Vaynberg <ig...@gmail.com>.
maybe just IConverter<?> getConverter(Class<?> cl)
-igor
On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <ig...@gmail.com> wrote:
> example below doesnt compile, so im not exactly sure how to override
> generified getconverter() properly ... do we need to change our
> generics decl somehow?
>
> -igor
>
> @Override
> public <Z> IConverter<Z> getConverter(Class<Z> type)
> {
> if (Integer.class.isAssignableFrom(type))
> {
> return new IConverter<Integer>()
> {
> private static final long serialVersionUID = 1L;
>
> public Integer convertToObject(String value, Locale locale)
> {
> return null;
> }
>
> public String convertToString(Integer value, Locale locale)
> {
> return null;
> }
>
> };
> }
> else
> {
> return super.getConverter(type);
> }
> }
>