This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new 4dec263d Refactor stream processing
4dec263d is described below

commit 4dec263d684f03065bee21efe477d2bb33134cf0
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Aug 1 14:19:00 2026 -0400

    Refactor stream processing
---
 src/main/java/org/apache/commons/cli/Options.java | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/cli/Options.java 
b/src/main/java/org/apache/commons/cli/Options.java
index 9d76967a..9088a389 100644
--- a/src/main/java/org/apache/commons/cli/Options.java
+++ b/src/main/java/org/apache/commons/cli/Options.java
@@ -25,6 +25,7 @@ import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * Main entry-point into the library.
@@ -227,12 +228,7 @@ public class Options implements Serializable {
         if (longOpts.containsKey(clean)) {
             return Collections.singletonList(clean);
         }
-        longOpts.keySet().forEach(longOpt -> {
-            if (longOpt.startsWith(clean)) {
-                matchingOpts.add(longOpt);
-            }
-        });
-        return matchingOpts;
+        return longOpts.keySet().stream().filter(s -> 
s.startsWith(clean)).collect(Collectors.toList());
     }
 
     /**

Reply via email to