Generic types are lost by the time the method is executed, so there's really
nothing the method implementation could check. Another fun example
is org.apache.wicket.model.Model#of(). The general subject is called type
erasure, and is one of the more confusing aspects of Java generics.

On Thu, Jul 28, 2011 at 4:45 PM, Ben Tilford <[email protected]> wrote:

> Without a Class argument how is it returning/casting correctly? Shouldn't
> it
> be
>
> public <W> IWrapModel<W> wrapOnInheritance(Component component,Class<W>
> type)
>
> to make W available within the method?
>
>
> On Thu, Jul 28, 2011 at 12:40 PM, Dan Retzlaff <[email protected]>
> wrote:
>
> > The first <W> let's the compiler know that the second <W> is a generic
> type
> > and not a reference to some class named W. It's just syntax.
> >
> > On Thu, Jul 28, 2011 at 10:48 AM, Niranjan Rao <[email protected]> wrote:
> >
> > > Ok, I admit it - I don't understand this function at all defined in
> > > IComponentInheritedModel
> > >
> > > public <W> IWrapModel<W> wrapOnInheritance(Component component)
> > >
> > > I don't understand meaning of <W> and IWrapModel<W>. I know generics
> > > generally, but this syntax has been baffling me. Based on what eclipse
> is
> > > trying to do, it seems like it will return IWrapModel<W>, but then what
> > does
> > > first <W> do? I tried some google searches, but could not find the
> > answer.
> > >
> > > Thanks,
> > >
> > > Niranjan
> > >
> > >
> ------------------------------**------------------------------**---------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<
> > [email protected]>
> > > For additional commands, e-mail: [email protected]
> > >
> > >
> >
>

Reply via email to