Skip to content

Commit 4dec263

Browse files
committed
Refactor stream processing
1 parent c9ffd67 commit 4dec263

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

src/main/java/org/apache/commons/cli/Options.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2525
import java.util.LinkedHashMap;
2626
import java.util.List;
2727
import java.util.Map;
28+
import java.util.stream.Collectors;
2829

2930
/**
3031
* Main entry-point into the library.
@@ -227,12 +228,7 @@ public List<String> getMatchingOptions(final String opt) {
227228
if (longOpts.containsKey(clean)) {
228229
return Collections.singletonList(clean);
229230
}
230-
longOpts.keySet().forEach(longOpt -> {
231-
if (longOpt.startsWith(clean)) {
232-
matchingOpts.add(longOpt);
233-
}
234-
});
235-
return matchingOpts;
231+
return longOpts.keySet().stream().filter(s -> s.startsWith(clean)).collect(Collectors.toList());
236232
}
237233

238234
/**

0 commit comments

Comments
 (0)