You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/07/10 03:52:24 UTC
DO NOT REPLY [Bug 30020] New: -
Method that add a Object to a Collection if it was not null
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