On Tue, Jan 25, 2011 at 11:42 AM, Greg Brown <[email protected]> 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

Reply via email to