fix(TDI-42183): Avoid locale dependent checks (#2715)

* fix(TDI-42183): Avoid locale dependent checks

* fix(TDI-42183): declare the code come from apache commons lang
This commit is contained in:
wang wei
2019-09-23 18:04:06 +08:00
committed by GitHub
parent 1f385ee333
commit 15216b8be3

View File

@@ -403,8 +403,25 @@ public class StringUtils {
return sb.toString();
}
/**
* check if string contains search string case-insensitivity
* the code is copied from apache commons-lang3 StringUtils and do some adjust to avoid the useless code
*/
public static boolean containsIgnoreCase(final String str, final String searchStr) {
if (str == null || searchStr == null) {
return false;
}
final int len = searchStr.length();
final int max = str.length() - len;
for (int i = 0; i <= max; i++) {
if (str.regionMatches(true, i, searchStr, 0, len)) {
return true;
}
}
return false;
}
/**
* return null value not "null" String when obj is null that is the only difference with String.valueOf(Object obj)
*