what do you have against butts? :)
-igor
On Tue, Apr 15, 2008 at 1:27 PM, Peter Ertl <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
> 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 <[EMAIL PROTECTED]>
> > >
> > >
> > > 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
> <[EMAIL PROTECTED]>
> > > > 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
> <[EMAIL PROTECTED]
> > > > >
> > > > >
> > > > >
> > > > > 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 <
> > > > > >
> > > > >
> > > > [EMAIL PROTECTED]>
> > > >
> > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > What is the compile error message?
> > > > > > >
> > > > > > > On Tue, Apr 15, 2008 at 3:10 PM, Igor Vaynberg <
> > > > > > >
> > > > > >
> > > > >
> > > > [EMAIL PROTECTED]
> > > >
> > > > >
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > >
> > > > > > > > maybe just IConverter<?> getConverter(Class<?> cl)
> > > > > > > >
> > > > > > > > -igor
> > > > > > > >
> > > > > > > >
> > > > > > > > On Tue, Apr 15, 2008 at 11:05 AM, Igor Vaynberg <
> > > > > > > >
> > > > > > >
> > > > > > [EMAIL PROTECTED]>
> > > > > >
> > > > > > >
> > > > > > > > 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
> > >
> > >
> >
>
>