commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henri Yandell <bay...@generationjava.com>
Subject Re: [Collections][SUBMIT] TypedList
Date Tue, 23 Apr 2002 19:38:24 GMT


On Tue, 23 Apr 2002, Stephen Colebourne wrote:

> > The way I did this was:
> >
> > TypedStructure interface. AbstractTypedStructure class.
> > IllegalTypeException exception.
> >
> > Then TypedSet/List/Map implement Set/List/Map and extend
> > AbstractTypedStructure.
>
> I'm not quite sure as to what benefits AbstractTypedStructure gives you. The
> implementation of TypedList makes use of the AbstractList class for its
> iterators and subList. Extending something else would cause problems...

I kept my getType/checkType stuff in the abstract class. However the
Predicate idea does away with needing this. We'd just use the same
Predicate for the map/list/set. Hopefully.

>
> > What is the point of the wrap method?
> >
> > Can I do:
> >     List list = TypedList(new LinkedList());   ????
>
> Yes, but the syntax is
> List list = TypedList.wrap(new LinkedList());
> However, as noted above, the iterator is based on AbstractList - not much
> use for LinkedList. I'll see if I can fix this ;-)

Little unsure what you're saying. Sounds like the only difference is that
you use a factory method where I tend to use a constructor. I love doing:

List list = new LimitedList( new SortedList( new LinkedList() ) );

etc etc.

I don't recall how to use reflection on static methods, only problem I
could think of with 'wrap'.

Hen


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message