pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calathus <calat...@gmail.com>
Subject Re: why ListButton.getListData returns List<?> ?
Date Tue, 25 Jan 2011 20:25:03 GMT
On Tue, Jan 25, 2011 at 12:10 PM, Greg Brown <gk_brown@verizon.net> wrote:

> It's true that it will eliminate the need for a cast, but the API is not
> pretty, and you still won't catch errors until runtime. If we really think
> that casting is a big deal (which I'm not sure I do), I'd much prefer adding
> a type parameter to the methods.
> G
>

I think you do not write Java code using these API directly(relying on
BXML), you would think the casting is not big deal.
These annoyance which is introduced by some compiler issue,delegating the
cost to end user is not good API design at all.

If you don't like to have two methods, it may just support List<Object>
version. anyway we can alway cast to any type with double cast!



>
>
> On Jan 25, 2011, at 3:01 PM, calathus wrote:
>
>
>
> On Tue, Jan 25, 2011 at 11:42 AM, Greg Brown <gk_brown@verizon.net> wrote:
>
>> > Since generic version may give wrong impression that it is type safe, it
>> may be better to provide two version for getter, one is just return
>> List<object>, another will return List<T> taking class value as the
>> argument. also we may use generic method for setter. see following sample
>> code.
>> ...
>> >         public List<Object> getList() {
>> >             return (List<Object>)ts;
>> >         }
>> >         public <T> List<T> getList(Class<T> cls) {
>> >             return (List<T>)ts;
>> >         }
>>
>> Yuck. I think it is probably best to leave it as-is.
>>
>
> I think this approach will eliminate using cast for adding element(which is
> very frequently used), while current one still requires cast.
> And I think most of case, the second case won't be required.
>
>
>
>
>
> --
> Cheers,
> calathus
>
>
>
>
>


-- 
Cheers,
calathus

Mime
View raw message