commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30020] New: - Method that add a Object to a Collection if it was not null
Date Sat, 10 Jul 2004 01:52:24 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30020>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30020

Method that add a Object to a Collection if it was not null

           Summary: Method that add a Object to a Collection if it was not
                    null
           Product: Commons
           Version: 3.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Collections
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: r.u.c.afonso@uol.com.br


It would be a new static method to CollectionUtils class. It would retur 
boolean because add() method from Collection returns a boolean. It would had 
only a line:

public static boolean addNotNull(Collection c, Object o) {
   return (o != null)? c.add(o): false;
}

Of course if c was null, it will throw a NullPointerException. 
Aparently it is possible use a PredicatedCollection with NotNullPredicate. But 
it will trhow a IllegalArgumentException if o was null. It is not interesting.

---------------------------------------------------------------------
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