commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sualeh Fatehi" <sua...@hotmail.com>
Subject commons lang: Comparisons with null support
Date Mon, 28 Feb 2005 19:46:53 GMT
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


Mime
View raw message