mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Use computeIfAbsent in CommandLineArgs.addOptionArg
Signed-off-by: junhyung8795 <junhyung8795@naver.com>
This commit is contained in:
committed by
Brian Clozel
parent
d883602919
commit
17e0daf8a1
+2
-4
@@ -46,11 +46,9 @@ class CommandLineArgs {
|
||||
* without an associated value — for example, "--foo" vs. "--foo=bar".
|
||||
*/
|
||||
public void addOptionArg(String optionName, @Nullable String optionValue) {
|
||||
if (!this.optionArgs.containsKey(optionName)) {
|
||||
this.optionArgs.put(optionName, new ArrayList<>());
|
||||
}
|
||||
List<String> values = this.optionArgs.computeIfAbsent(optionName, key -> new ArrayList<>());
|
||||
if (optionValue != null) {
|
||||
this.optionArgs.get(optionName).add(optionValue);
|
||||
values.add(optionValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user