if (searchString.isEmpty()) {
return emptyStringMatchesAll? Predicates.<String>alwaysTrue() : Predicates.equalTo(searchString);
}
if (regex) {
int flag = caseSensitive ? 0 : Pattern.CASE_INSENSITIVE;
return new RegularExpressionPredicate(searchString, false, flag);
} else {
return caseSensitive ? StringPredicates.contains(searchString) :
StringPredicates.containsIgnoreCase(searchString);
}
}