Merge branch '6.0.x'

This commit is contained in:
Stephane Nicoll 2023-08-23 10:47:32 +02:00
commit bf2cdcb1f2
1 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,7 +46,11 @@ import org.springframework.util.StringUtils;
* // ...
* }</pre>
*
* See {@link CommandLinePropertySource} for complete general usage examples.
* <p>If an option has several representations, the most descriptive is expected
* to be set last, and is used as the property name of the associated
* {@link EnumerablePropertySource#getPropertyNames()}.
*
* <p>See {@link CommandLinePropertySource} for complete general usage examples.
*
* <p>Requires JOpt Simple version 4.3 or higher. Tested against JOpt up until 5.0.
*
@ -88,9 +92,9 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySource<Opt
public String[] getPropertyNames() {
List<String> names = new ArrayList<>();
for (OptionSpec<?> spec : this.source.specs()) {
// Last option is expected to be the most descriptive.
String lastOption = CollectionUtils.lastElement(spec.options());
if (lastOption != null) {
// Only the longest name is used for enumerating
names.add(lastOption);
}
}