boolean (@NotNull String str, Object value, boolean literalMatch) { String patternValue; if (value instanceof String) { patternValue = (String)value; } else if (value instanceof Character) { patternValue = value.toString(); } else { return false; } if (literalMatch) return !str.contains(patternValue); if (patternValue.length() > MAX_PATTERN_LENGTH) return false; Pattern regex; try { regex = Pattern.compile(patternValue); } catch (PatternSyntaxException e) { return false; } return !regex.matcher(str).find(); }