JBIterable<String> (@NotNull FileType fileType, boolean sort, @NotNull FileTypeManager fileTypeManager) { JBIterable<String> result = JBIterable.from(fileTypeManager.getAssociations(fileType)) .filterMap(o -> { if (o instanceof ExtensionFileNameMatcher) { return StringUtil.nullize(((ExtensionFileNameMatcher)o).getExtension()); } else if (o instanceof WildcardFileNameMatcher) { String pattern = ((WildcardFileNameMatcher)o).getPattern(); if (pattern.startsWith("*.") && pattern.indexOf('*', 1) < 0 && pattern.indexOf('?', 1) < 0) { return StringUtil.nullize(pattern.substring(2)); } } return null; }); if (sort) { String def = fileType.getDefaultExtension(); return result.sort((o1, o2) -> o1.equals(o2) ? 0 : o1.equals(def) ? -1 : o2.equals(def) ? 1 : Integer.compare(o1.length(), o2.length())); } return result; }