Polishing

This commit is contained in:
Juergen Hoeller
2018-01-19 19:35:02 +01:00
parent a73d9bbed5
commit 8b5a013423
12 changed files with 108 additions and 128 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -23,6 +23,8 @@ import java.util.List;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import org.springframework.util.StringUtils;
/**
* {@link CommandLinePropertySource} implementation backed by a JOpt {@link OptionSet}.
*
@@ -84,13 +86,13 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySource<Opt
public String[] getPropertyNames() {
List<String> names = new ArrayList<String>();
for (OptionSpec<?> spec : this.source.specs()) {
List<String> aliases = new ArrayList<String>(spec.options());
List<String> aliases = spec.options();
if (!aliases.isEmpty()) {
// Only the longest name is used for enumerating
names.add(aliases.get(aliases.size() - 1));
}
}
return names.toArray(new String[names.size()]);
return StringUtils.toStringArray(names);
}
@Override