commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <>
Subject Re: [Collections][SUBMIT] TypedList
Date Tue, 23 Apr 2002 19:31:39 GMT
Yes, the use of Predicate makes sense to me. The 'simple' instanceof
Predicate can be setup using a static factory method on TypedList. I'll take
a look at doing this.


BTW: I guess I'll have to rename it, any better suggestions than

From: Jack, Paul <>
> Hi Steve,
> Your TypedList got me thinking...At first I thought, wouldn't
> it be nice to specify a parameter that would allow the null
> element (sometimes I need a list that allows nulls)...then I
> got to thinking, actually wouldn't it be nice if the validate()
> method could be overridden by a subclass to allow more than one
> class type...then I thought, actually, wouldn't it be nice if
> the validation were completely generic, so that you supplied the
> validation routine in the constructor of the list...then I
> realized, the collections package already defines an interface
> for validations (Predicate)...
> you think it's a good idea to alter TypedList so that it
> takes a Predicate in its constructor?  You could then supply a
> concrete Predicate that does the Class.isInstance check...
> -Paul
> -----Original Message-----
> From: Stephen Colebourne []
> Sent: Sunday, April 21, 2002 2:13 PM
> To: Jakarta Commons Developers List
> Subject: [Collections][SUBMIT] TypedList
> Hi,
> After a quick check, I could find no implementation of a type checking
> in collections. As I needed it, I have created one. Here is the class
> javadoc:
>  * TypedList is a list wrapper that supports type checking. Only elements
>  * of the specified type (or a subclass) can be added to the list. An
>  * attempt to add a different kind of object, or null, will cause an
>  * <tt>IllegalArgumentException</tt>.
>  * <p>
>  * Constructing a new instance of this class will use an ArrayList behind
>  * the scenes. Alternatively, the static <tt>wrap</tt> method can be
>  * used to wrap any object implementing List.
> The code is attached as a zip. Feedback welcome on whether this is
> for inclusion in the collections area.
> Stephen
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message