MaskMatcher (final @NotNull String pattern) { int len = pattern.length(); if (len > 1 && pattern.indexOf('?') < 0) { if (pattern.charAt(0) == '*' && pattern.indexOf('*', 1) < 0) { return new SuffixMatcher(pattern.substring(1)); } if (pattern.indexOf('*') == len - 1) { return new PrefixMatcher(pattern.substring(0, len - 1)); } if (len > 2 && pattern.charAt(0) == '*' && pattern.indexOf('*', 1) == len - 1) { return new InfixMatcher(pattern.substring(1, len - 1)); } } return new RegexpMatcher(pattern); }