On Sat, Jun 13, 2009 at 8:13 AM, Martin
Makundi<martin.maku...@koodaripalvelut.com> wrote:
> Hi!
>
> Yes.. this is true but not ideally consistent. More consistent would be
>
> DropDownChoice<? extends BaseClass> dropDown = new DropDownChoice<?
> extends BaseClass>("id");

You can't instantiate with a wildcard type.  That's not allowed by the
Java language.

>
> in such a way that dropDown.getChoiceRenderer() would be automatically
> of type <BaseClass>.
>
> One solution would be to change the signature of DropDownChoice (and
> selectchoices ...):
>
> public class DropDownChoice<T> extends .... into
>
> public class DropDownChoice<T, S extends T> extends .... in such a manner that
>
> DropDownChoice<? extends BaseClass=T> dropDown = new DropDownChoice<?
> extends BaseClass=T>("id");
> and
>
> DropDownChoice.getChoiceRenderer() : S
>
> That would work... both ways?

I, for one, would be -1 to such a change (non-binding of course).  Why
do you need the ChoiceRenderer to support a specific subtype of
BaseClass?  If you have a ChoiceRenderer<BaseClass> (which is what you
get if you declare your variable as I suggest), you can pass it any
type that extends BaseClass.  You do not need to declare your
variables with the wildcard.  What consistency are you looking for?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to