boolean (@Nullable CharSequence s1, @Nullable CharSequence s2, boolean caseSensitive) { if (s1 == s2) return true; if (s1 == null || s2 == null) return false; if (s1.length() != s2.length()) return false; if (caseSensitive) { for (int i = 0; i < s1.length(); i++) { if (s1.charAt(i) != s2.charAt(i)) { return false; } } } else { for (int i = 0; i < s1.length(); i++) { if (!charsEqualIgnoreCase(s1.charAt(i), s2.charAt(i))) { return false; } } } return true; }