commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [Collections] Add Object to Collection if not null
Date Fri, 09 Jul 2004 19:23:06 GMT
I quite like this idea, as it is simple and does cover a case I can see
people finding.

It might be worth opening a bugzilla entry for it so it is kept track of.

Stephen

----- Original Message -----
From: "Rafael U. C. Afonso" <r.u.c.afonso@uol.com.br>
I was looking for a method that adds a object in a Collection
if this object is not null, but I did not find it in
Collections. I thought that this method would be useful in
CollectionUtils class. Is there a method like this? If it
does not exist I would like suggest this. It could be
implemented like this:

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

Like Collection.add(Object) returns boolean, this method will
boolean too.
What is your opinion?




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


Mime
View raw message