List<FileNameMatcher> (@NotNull Object context, @NotNull String semicolonDelimitedTokens, @NotNull Function<? super String, ? extends FileNameMatcher> matcherFactory) { if (semicolonDelimitedTokens.isEmpty()) { return Collections.emptyList(); } StringTokenizer tokenizer = new StringTokenizer(semicolonDelimitedTokens, FileTypeConsumer.EXTENSION_DELIMITER, false); List<FileNameMatcher> list = new ArrayList<>(StringUtil.countChars(semicolonDelimitedTokens, ';')+1); while (tokenizer.hasMoreTokens()) { String ext = tokenizer.nextToken().trim(); if (Strings.isEmpty(ext)) { throw new InvalidDataException("Token must not be empty but got: '"+semicolonDelimitedTokens+"' in "+context); } list.add(matcherFactory.apply(ext)); } return list; }