List of utility methods to do String Equal
boolean | areEqualIgnoreCase(String s1, String s2) are Equal Ignore Case if (s1 == null && s2 == null) return true; if (s1 != null) { s1 = s1.toLowerCase(); return s2 != null && s1.equals(s2.toLowerCase()); } else { return false; |
boolean | areEqualIgnoreNull(String value1, String value2, boolean caseSensitive) Compares the given values and returns true if they are equal. if (value1 == null || value1.equals("")) { return true; } else { if (caseSensitive && value1.equals(value2)) { return true; } else if (!caseSensitive && value1.equalsIgnoreCase(value2)) { return true; } else { ... |
boolean | areEqualLexemes(String l1, String l2) Sometimes different API methods deliver different results, e.g. if (l1.equals(l2)) { return true; String l1_relaxed = l1.replaceAll(" ", "_"); String l2_relaxed = l2.replaceAll(" ", "_"); if (l1_relaxed.equals(l2_relaxed)) { return true; return false; |
boolean | areEquals(final String origin, final String checkWith) are Equals return !isNullOrEmpty(origin) && origin.equals(checkWith);
|
boolean | areEquals(final String s1, final String s2) Compare two String to see if they are equals (both null is ok). return s1 == null ? s2 == null : s1.equals(s2);
|
boolean | areEqualsIgnoreCaseAndTrim(final String s1, final String s2) Compare two String to see if they are equals ignoring the case and the blank spaces (both null is ok). if (s1 == null && s2 == null) { return true; } else if (s1 != null && s2 != null) { return s1.trim().equalsIgnoreCase(s2.trim()); } else { return false; |
boolean | areEqualXMLValues(String s1, String s2) Test if two strings are equal in XML. return ((s1 == null && s2 == null) || (s1 == null && isEmpty(s2)) || (isEmpty(s1) && s2 == null)
|| (s1 != null && s1.equals(s2)));
|
boolean | areStringEquals(String s1, String s2) Indicates if two Strings are equals, managing null. if (s1 == null) { return s2 == null; return s1.equals(s2); |
boolean | areStringEquals(String string1, String string2) Checks if two strings are equals. if (string1 == null && string2 == null) { return false; } else if (string1 != null && !string1.equals(string2)) { return false; } else if (string2 != null && !string2.equals(string1)) { return false; return true; ... |
boolean | areStringsEqual(String one, String two) Checks if two strings are equal - handles nulls boolean nullDiff = one == null ^ two == null; boolean valueDiff = one != null && two != null && !one.equals(two); return !nullDiff && !valueDiff; |