commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections CollectionUtils.java
Date Sat, 17 Jul 2004 21:38:33 GMT
scolebourne    2004/07/17 14:38:33

  Modified:    collections RELEASE-NOTES.html
               collections/src/test/org/apache/commons/collections
                        TestCollectionUtils.java
               collections/src/java/org/apache/commons/collections
                        CollectionUtils.java
  Log:
  CollectionUtils.addIgnoreNull new method
  bug 30020, from Rafael U. C. Afonso
  
  Revision  Changes    Path
  1.69      +3 -3      jakarta-commons/collections/RELEASE-NOTES.html
  
  Index: RELEASE-NOTES.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/RELEASE-NOTES.html,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- RELEASE-NOTES.html	17 Jul 2004 21:02:47 -0000	1.68
  +++ RELEASE-NOTES.html	17 Jul 2004 21:38:33 -0000	1.69
  @@ -34,12 +34,12 @@
   
   <center><h3>NEW CLASSES</h3></center>
   <ul>
  -<li>LoopingListIterator - When the end of the list is reached the iteration continues
from the start</li>
  +<li>LoopingListIterator - When the end of the list is reached the iteration continues
from the start [30166]</li>
   </ul>
   
   <center><h3>ENHANCEMENTS</h3></center>
   <ul>
  -<li>........</li>
  +<li>CollectionUtils.addIgnoreNull - Adds to the collection if the value being added
is not null [30020]</li>
   </ul>
   
   <center><h3>BUG FIXES</h3></center>
  @@ -49,5 +49,5 @@
   
   <center><h3>JAVADOC</h3></center>
   <ul>
  -<li>........</li>
  +<li>MapUtils.safeAddToMap - Better comment</li>
   </ul>
  
  
  
  1.40      +17 -1     jakarta-commons/collections/src/test/org/apache/commons/collections/TestCollectionUtils.java
  
  Index: TestCollectionUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestCollectionUtils.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- TestCollectionUtils.java	26 Jun 2004 10:00:42 -0000	1.39
  +++ TestCollectionUtils.java	17 Jul 2004 21:38:33 -0000	1.40
  @@ -965,6 +965,22 @@
           assertEquals(new Integer(4), set.iterator().next());
       }
   
  +    //-----------------------------------------------------------------------
  +    public void testAddIgnoreNull() {
  +        Set set = new HashSet();
  +        set.add("1");
  +        set.add("2");
  +        set.add("3");
  +        assertEquals(false, CollectionUtils.addIgnoreNull(set, null));
  +        assertEquals(3, set.size());
  +        assertEquals(false, CollectionUtils.addIgnoreNull(set, "1"));
  +        assertEquals(3, set.size());
  +        assertEquals(true, CollectionUtils.addIgnoreNull(set, "4"));
  +        assertEquals(4, set.size());
  +        assertEquals(true, set.contains("4"));
  +    }
  +
  +    //-----------------------------------------------------------------------
       public void testPredicatedCollection() {
           Predicate predicate = new Predicate() {
               public boolean evaluate(Object o) {
  
  
  
  1.62      +20 -7     jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java
  
  Index: CollectionUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- CollectionUtils.java	27 Apr 2004 20:00:18 -0000	1.61
  +++ CollectionUtils.java	17 Jul 2004 21:38:33 -0000	1.62
  @@ -633,11 +633,24 @@
           return outputCollection;
       }
   
  +    //-----------------------------------------------------------------------
  +    /**
  +     * Adds an element to the collection unless the element is null.
  +     * 
  +     * @param collection  the collection to add to, must not be null
  +     * @param object  the object to add, if null it will not be added
  +     * @return true if the collection changed
  +     * @throws NullPointerException if the collection is null
  +     */
  +    public static boolean addIgnoreNull(Collection collection, Object object) {
  +        return (object == null ? false : collection.add(object));
  +    }
  +    
       /**
        * Adds all elements in the iteration to the given collection.
        * 
  -     * @param collection  the collection to add to
  -     * @param iterator  the iterator of elements to add, may not be null
  +     * @param collection  the collection to add to, must not be null
  +     * @param iterator  the iterator of elements to add, must not be null
        * @throws NullPointerException if the collection or iterator is null
        */
       public static void addAll(Collection collection, Iterator iterator) {
  @@ -649,8 +662,8 @@
       /**
        * Adds all elements in the enumeration to the given collection.
        * 
  -     * @param collection  the collection to add to
  -     * @param enumeration  the enumeration of elements to add, may not be null
  +     * @param collection  the collection to add to, must not be null
  +     * @param enumeration  the enumeration of elements to add, must not be null
        * @throws NullPointerException if the collection or enumeration is null
        */
       public static void addAll(Collection collection, Enumeration enumeration) {
  @@ -662,8 +675,8 @@
       /** 
        * Adds all elements in the array to the given collection.
        * 
  -     * @param collection  the collection to add to, may not be null
  -     * @param elements  the array of elements to add, may not be null
  +     * @param collection  the collection to add to, must not be null
  +     * @param elements  the array of elements to add, must not be null
        * @throws NullPointerException if the collection or array is null
        */
       public static void addAll(Collection collection, Object[] elements) {
  
  
  

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


Mime
View raw message