public static @NotNull Condition<CharSequence> createFileMaskCondition(@Nullable String filter) throws PatternSyntaxException {
    if (StringUtil.isEmpty(filter)) {
      return Conditions.alwaysTrue();
    }

    StringBuilder pattern = new StringBuilder();
    StringBuilder negativePattern = new StringBuilder();
    List<String> masks = StringUtil.split(filter, ",");

    for (String mask : masks) {
      mask = mask.trim();
      if (mask.startsWith("!")) {
        negativePattern.append((negativePattern.isEmpty()) ? "" : "|").append("(").append(PatternUtil.convertToRegex(mask.substring(1))).append(")");
      }
      else {
        pattern.append((pattern.isEmpty()) ? "" : "|").append("(").append(PatternUtil.convertToRegex(mask)).append(")");
      }
    }

    if (pattern.isEmpty()) pattern.append(PatternUtil.convertToRegex("*"));

    return new Condition<>() {
      final Pattern regExp = Pattern.compile(pattern.toString(), Pattern.CASE_INSENSITIVE);
      final Pattern negativeRegExp = negativePattern.isEmpty() ? null : Pattern.compile(negativePattern.toString(), Pattern.CASE_INSENSITIVE);

      @Override
      public boolean value(CharSequence input) {
        return regExp.matcher(input).matches() && (negativeRegExp == null || !negativeRegExp.matcher(input).matches());
      }
    };
  }
public static @NotNull Condition<CharSequence> createFileMaskCondition(@Nullable String filter)