There's the rub.  It's not that the functionality of ListUtils has simply
been moved to CollectionUtils, it's that CollectionUtils does something
slightly different (and I would argue, more appropriate) than the equivalent
ListUtils function.

For example, given two lists: A { 1, 1, 1, 2, 2 } and B { 1, 2, 2, 3 }:

 * ListUtils.intersection(A,B) returns { 1, 2, 2 }
 * ListUtils.intersection(B,A) returns { 1, 1, 1, 2, 2 }
 * CollectionUtils.intersection returns { 1, 2, 2 } for both (A,B) and (B,A)

I would argue that this is a "bug" in ListUtils--intersection should be
symmetric--but I assume that that functionality as implemented is how it's
being used, so I don't think that we can simply point anyone to
CollectionUtils.intersection method.

Actually, looking over it, I think union()and subtract() should give the
same results for both impls., only intersection() and sum() (which is
disjunction() in CollectionUtils) should be different.  So we do have
functional equivalents for two of the ListUtils methods, and we could simply
deprecate those and point to CollectionUtils. 

But it seems silly to me to have deprecated methods before we even get to
the 1.0 release.  What are we maintaining compatibility with?  (The answer
would be Avalon, but why not let Avalon use their internal ListUtils until
they're ready to move to CollectionUtils directly.  What's the point of
keeping it in commons-collections?)


-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 16, 2001 6:12 PM
To: '[EMAIL PROTECTED]'
Subject: Re: [Collections] Deprecating ListUtils

On Wed, 16 May 2001, Waldhoff, Rodney wrote:

> Does anyone have any strong objections to removing this class from the
> Collections distribution?  CollectionUtils is similar in spirit but
> different in semantics, and I think all of this functionality could be
build
> from addAll/removeAll/retainAll methods in the Collection interface.
> 

I'm OK for deprecating if CollectionUtils can do everything and more.  But
removing seems a little abrupt (even though technically we haven't done a
1.0 release yet).  How about recasting the functionality in terms of calls
to the corresponding CollectionUtils methods?

Craig


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 16, 2001 5:19 PM
> To: [EMAIL PROTECTED]
> Subject: cvs commit:
> jakarta-commons/collections/src/java/org/apache/commons/collections
> ListUtils.java
> 
> 
> rwaldhoff    01/05/16 15:19:27
> 
>   Modified:    collections/src/java/org/apache/commons/collections
>                         ListUtils.java
>   Log:
>   Deprecating.  I'd like to remove this class, if no one has any issues.
>   
>   Revision  Changes    Path
>   1.2       +12 -11
>
jakarta-commons/collections/src/java/org/apache/commons/collections/ListUtil
> s.java
>   
>   Index: ListUtils.java
>   ===================================================================
>   RCS file:
>
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collection
> s/ListUtils.java,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- ListUtils.java  2001/04/22 19:56:37     1.1
>   +++ ListUtils.java  2001/05/16 22:19:23     1.2
>   @@ -16,19 +16,20 @@
>     *
>     * @author  <a href="mailto:[EMAIL PROTECTED]";>Federico Barbieri</a>
>     * @author  <a href="mailto:[EMAIL PROTECTED]";>Peter Donald</a>
>   + * @deprecated See {@link
> org.apache.commons.collections.CollectionUtils}.
>     */
>    public class ListUtils
>    {
>   -    public static List intersection( final List list1, final List list2
)
> 
>   +    public static List intersection( final List list1, final List list2
)
>        {
>            final ArrayList result = new ArrayList();
>            final Iterator iterator = list2.iterator();
>    
>   -        while( iterator.hasNext() ) 
>   +        while( iterator.hasNext() )
>            {
>                final Object o = iterator.next();
>    
>   -            if ( list1.contains( o ) ) 
>   +            if ( list1.contains( o ) )
>                {
>                    result.add( o );
>                }
>   @@ -36,27 +37,27 @@
>    
>            return result;
>        }
>   -    
>   -    public static List subtract( final List list1, final List list2 ) 
>   +
>   +    public static List subtract( final List list1, final List list2 )
>        {
>            final ArrayList result = new ArrayList( list1 );
>            final Iterator iterator = list2.iterator();
>    
>   -        while( iterator.hasNext() ) 
>   +        while( iterator.hasNext() )
>            {
>                result.remove( iterator.next() );
>            }
>    
>            return result;
>        }
>   -    
>   -    public static List sum( final List list1, final List list2 ) 
>   +
>   +    public static List sum( final List list1, final List list2 )
>        {
>   -        return subtract( union( list1, list2 ), 
>   +        return subtract( union( list1, list2 ),
>                             intersection( list1, list2 ) );
>        }
>   -    
>   -    public static List union( final List list1, final List list2 ) 
>   +
>   +    public static List union( final List list1, final List list2 )
>        {
>            final ArrayList result = new ArrayList( list1 );
>            result.addAll( list2 );
>   
>   
>   
> 

Reply via email to