List<String> (String fileText, boolean trim, boolean strict, String... prefixes) { if (prefixes.length == 0) { throw new IllegalArgumentException("Please specify the prefixes to check"); } List<String> result = new ArrayList<>(); List<String> cleanedPrefixes = cleanDirectivesFromComments(Arrays.asList(prefixes)); for (String line : fileNonEmptyCommentedLines(fileText)) { for (String prefix : cleanedPrefixes) { if (line.startsWith(prefix)) { String noPrefixLine = line.substring(prefix.length()); if (noPrefixLine.isEmpty() || Character.isWhitespace(noPrefixLine.charAt(0)) || Character.isWhitespace(prefix.charAt(prefix.length() - 1))) { result.add(trim ? noPrefixLine.trim() : StringUtil.trimTrailing(StringsKt.drop(noPrefixLine, 1))); break; } else if (strict) { throw new AssertionError( "Line starts with prefix \"" + prefix + "\", but doesn't have space symbol after it: " + line); } } } } return result; }