If the subclass wants type safety (returning T rather than Object),
then they would override getModelObject().  This is allowed because of
Java's covariant return types feature.  However, there's no such thing
as covariant parameter types, so overriding the setter won't work.

On Tue, Jun 10, 2008 at 9:54 AM, Ricky <[EMAIL PROTECTED]> wrote:
> I may be the dumb kid on the block, but why do we need to "override"
> setModel and getModel( ) once it has already been done in Component class? (
> meaning just have it in component class and then let all subclasses use the
> same methods?)
>
> Am i missing something?
>
> Rick
>
> On Sat, Jun 7, 2008 at 2:49 PM, Timo Rantalaiho <[EMAIL PROTECTED]>
> wrote:
>
>> On Sat, 07 Jun 2008, Igor Vaynberg wrote:
>> > i dont think listitem#setmodel is restricted in your example.to T in
>> ListItem<T>
>> >
>> > >    public <T> ListItem setModel(IModel<T> model)
>> >
>> > the first <T> hides the T of ListItem<T> so you might as well have
>> > said <X> setModel(IModel<X> model)
>>
>> Heh, you're right of course.
>>
>> There doesn't seem to be an easy way out, if you want to
>> bind the type of the component with the type of its model
>> only in a part of the Component inheritance hierarchy.
>>
>> I still find loosening the model type checks also in
>> parametrised subclasses of Component a viable alternative
>> for 1.4 (with less reuse of type variable names than what
>> I'm guilty of :)). That is if we want to provide a fairly
>> compatible alternative for migrating from 1.3.
>>
>> But on longer term, decoupling IModel from Component might
>> be the best thing to have come out of this generics episode.
>>
>> Best wishes,
>> Timo
>>
>> --
>> Timo Rantalaiho
>> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to