List of utility methods to do String Compare
int | compare(String s1, String s2) Comare two string return s1 == null ? (s2 == null ? 0 : -1) : s1.compareTo(s2);
|
int | compare(String lhs, String rhs) compare if (lhs == null) { return rhs == null ? 0 : 1; return rhs == null ? -1 : lhs.compareTo(rhs); |
boolean | compare(String str1, String str2) compare return (str1 == null || str2 == null) ? str1 == str2 : str1
.equals(str2);
|
int | compareToIgnoreCase(String s1, String s2, boolean nullsAreGreater) Compares two strings, guarding against nulls. if (s1 == s2) { return 0; if (s1 == null) { return nullsAreGreater ? 1 : -1; if (s2 == null) { return nullsAreGreater ? -1 : 1; ... |
int | compareToIgnoreCase(String s1, String s2, boolean nullsAreGreater) Compares two strings, guarding against nulls. if (s1 == s2) { return 0; if (s1 == null) { return nullsAreGreater ? 1 : -1; if (s2 == null) { return nullsAreGreater ? -1 : 1; ... |
int | compare(String s1, String s2) compare if (isNullOrEmpty(s1) && isNullOrEmpty(s2)) { return 0; } else if (isNullOrEmpty(s1)) { return 1; } else if (isNullOrEmpty(s2)) { return -1; return s1.compareToIgnoreCase(s2); ... |