commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <>
Subject RE: [collections] New utility methods for CollectionUtils & ListUtils
Date Wed, 01 Feb 2006 02:59:33 GMT
1.  +1 on not using Commons Lang as a dependency.

2.  I would agree that this is a bit specialized.  I'm -0 on including it.

3.  The removeNulls() method could be interesting, but I would not limit it
to lists.  You could use CollectionUtils.filter() and an "isNotNull"

-----Original Message-----
From: Stephen Colebourne [] 
Sent: Tuesday, January 31, 2006 4:35 PM
To: Jakarta Commons Developers List
Subject: Re: [collections] New utility methods for CollectionUtils &

Matt Blum wrote:
> The proposed CollectionUtils method is currently called cloneCollection,
> could be called deepClone.  It takes any Collection as a parameter, and
> attempts to create a clone of it and every object contained within it.  It
> tries a couple of different processes to do this, starting with using
> reflection to find the objects' clone method; if they don't have such a
> method but are Serializable, it uses Commons Lang SerializationUtils'
> method to clone them.  If it can't do that, either, it will just copy by
> reference.  It will recursively iterate through any sub-Collections as
> meaning that circular references will cause it to generate a stack
> overflow.  I've found it to be very useful.

This could be useful, but would need to be done without a dependency on 
commons-lang. Practically, it could just be the application of a 
Transformer to each element in the collection resulting in a new collection.

> The main proposed ListUtils method is simply called move, and takes a
> an index, and a distance as parameters.  It will move the element in the
> List at the specified index the specified distance, which can either be
> positive or negative.  It will wrap around, so that, in a List of length
> three (say), moving an element a distance of -2 would have the same effect
> as moving it 1.  It will throw IndexOutOfBoundsException, as you'd expect,
> if the specified index is out of range.

This seems a little specialised, although I'm open to other views.

> I have another proposed ListUtils method, called removeNulls, which as
> expect simply removes nulls from a list.

I have coded this before and it is useful.

If you would like to write a patch, perhaps for the null remove first, 
then follow
creating a bugzilla request prefixed by [collections]


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

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

View raw message