List<String> (List<String> options, String name) { if (options.isEmpty()) { return Collections.emptyList(); } else { boolean useValue = false; List<String> result = new ArrayList<>(); for (String option : options) { if (option.equals(name)) { useValue = true; continue; } else if (useValue) { useValue = false; } else if (option.startsWith(name) && option.length() > name.length() + 1 && option.charAt(name.length()) == '=') { option = option.substring(name.length() + 1); } else { continue; } if (!option.isEmpty()) { result.add(option); } } return result; } }