Skip to content

Commit b2948a6

Browse files
committed
Use Stream.findFirst()
1 parent aede31b commit b2948a6

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,11 +1030,9 @@ private void processPropertiesFromValues(final Properties props, final List<Stri
10301030
private Option resolveOption(final String optionName) {
10311031
final String actual = Util.stripLeadingHyphens(optionName);
10321032
if (actual != null) {
1033-
for (final Option option : options) {
1034-
if (actual.equals(option.getOpt()) || actual.equals(option.getLongOpt())) {
1035-
return option;
1036-
}
1037-
}
1033+
return options.stream()
1034+
.filter(opt -> actual.equals(opt.getOpt()) || actual.equals(opt.getLongOpt()))
1035+
.findFirst().orElse(null);
10381036
}
10391037
return null;
10401038
}

0 commit comments

Comments
 (0)