I believe that my first submission to commons was a proposed typed
collection. Now here I am maintaining the package and we've come full
circle....

My original proposal was changed to become the Predicated Collection
decorators. Unfortunately, these got stymied by politics over which project
got to implement the predicates.

Anyway, you can (with just a little teaking from the CVS), write:
List list = ListUtils.predicatedList(new ArrayList(),
PredicateUtils.instanceofPredicate(String.class);

So, the question is whether there is enough justification for a
'convenience' implementation of TypedList et al.
List list = new TypedList(String.class);

The problem is where do you stop? Should it allow nulls? etc. the Predicate
route is more flexible. Overall, I think I'm +0.

Stephen

> So once again, the question is: in a world where Java 1.3 may be the
> only show in town for at least another 6 months or so (and possibly
> longer than that), would typed Collections be a useful tool?
>
> The amount of work required to implement these classes is trivial.  I
> wrote a TypedCollection class in about a 1/2 hour (and I code pretty
> slowly).
>
> Is is not wasted effort if type validation is something you would like,
> and you do not have access to 1.5, 1.4, or any prototype compilers or
> JVMs.
>
>
>
> On Thu, 2003-03-06 at 20:07, David Graham wrote:
> > You don't need 1.5 to use generics because you can download the
prototype
> > implementation already.  This further alleviates any need to duplicate
this
> > effort in Jakarta.  IMO, all this redundant work just to avoid casting
isn't
> > worth it.
> >
> > David
> >
> >
> >
>
> > >
> > > > It seems like a waste of time to write/maintain code that will be
> > >obsolete
> > > > quite soon.  I don't find casting collection objects to be terribly
> > >painful
> > > > and 1.5 will provide the function you would be coding.
> > > >
> > > > David
> > >
> > >It is true that Java 1.5 will include generics, and that any typed
> > >Collections that I create will eventually be replaced.  However, it
> > >seems to me that Java 1.5 will not be available anytime soon, so any
> > >classes written to solve this problem will not be obsolete for a good
> > >while.
> > >
> > >Even after the release of 1.5, not all developers will have access to
> > >it.  The HP-UX production machines at my current job are still running
> > >1.3, due to a kernel upgrade that 1.4 requires.  I'm sure that a lot of
> > >developers are in similar situations.
> > >
> > >It seems that the general Jakarta philosophy still leans toward
> > >supporting Java 1.3 at a minimum.  So, the question isn't so much about
> > >the possibility of these classes being replaced by better
> > >versions from Sun, but whether or not typed Collections would be a
> > >useful addition to the collections package.  I am going to write the
> > >classes either way, I was just wondering if anyone else was interested.
> > >
> > >I wasn't proposing to get rid of the casting involved when retrieving
> > >Objects from Collections, there is no way to do that while implementing
> > >Collection or Map.  I was proposing overrides to add(Object),
> > >addAll(Collection), and the Constructors, to add validation to the
input
> > >Objects or Collections.  Anyone sending or receiving a Collection could
> > >instantly validate whether the content is what they expect, rather than
> > >casting and getting a ClassCastException along the way.  I would
imagine
> > >that illegal classes would still throw some type of RuntimeException,
> > >perhaps a custom Exception which is more descriptive than ClassCast.
> > >
> > >Anyone else agree/disagree?
> > >
> > >
> > > > >Is there any interest in creating typed Collections?  Even though
it
> > > > >looks like Java is providing generics with 1.5, this could serve as
a
> > > > >good holdover until then,
> > > > >
> > > > >- a TypedCollection(Integer.class) would only allow Integers to its
add
> > > > >methods
> > > > >
> > > > >- a TypedMap(String.class, Integer.class) would only allow String
keys
> > > > >and Integer values
> > > > >
> > > > >I understand that this type of thing could already by done using
> > > > >Predicates and
> > >
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > _________________________________________________________________
> > MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
> > http://join.msn.com/?page=features/virus
> >
> >
> > ---------------------------------------------------------------------
> > 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]
>


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

Reply via email to