You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2005/02/28 22:39:15 UTC

Re: [lang] commons lang: Comparisons with null support

You may find NullComparator in [collections] useful.
Stephen

----- Original Message ----- 
From: "Sualeh Fatehi" <su...@hotmail.com>
>I have not done an extensive search of the mailing list archives, but I was
> wondering if something like the following comparison functions with 
> support
> for null values may be useful in commons lang StringUtils (and also
> DateUtils and NumberUtils):
>
> public static int compare(String left, String right) {
>  if (left == right) {
>    return 0;
>  }
>  if (left == null) {
>    return -1;
>  }
>  if (right == null) {
>    return 1;
>  }
>  return left.compareTo(right);
> }
>
> Sualeh.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


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