FileNameMatcher (@NotNull String pattern) { if (pattern.startsWith("*.") && pattern.indexOf('*', 2) < 0 && pattern.indexOf('.', 2) < 0 && pattern.indexOf('?', 2) < 0) { return new ExtensionFileNameMatcher(StringUtil.toLowerCase(pattern.substring(2))); } if (pattern.contains("*") || pattern.contains("?")) { return new WildcardFileNameMatcher(pattern); } return new ExactFileNameMatcher(pattern); }