Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -193,27 +193,30 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
|
||||
/** The default name of the property representing non-option arguments: {@value} */
|
||||
public static final String DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME = "nonOptionArgs";
|
||||
|
||||
|
||||
private String nonOptionArgsPropertyName = DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@code CommandLinePropertySource} having the default name {@value
|
||||
* #COMMAND_LINE_PROPERTY_SOURCE_NAME} and backed by the given source object.
|
||||
* Create a new {@code CommandLinePropertySource} having the default name
|
||||
* {@value #COMMAND_LINE_PROPERTY_SOURCE_NAME} and backed by the given source object.
|
||||
*/
|
||||
public CommandLinePropertySource(T source) {
|
||||
super(COMMAND_LINE_PROPERTY_SOURCE_NAME, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link CommandLinePropertySource} having the given name and backed by
|
||||
* the given source object.
|
||||
* Create a new {@link CommandLinePropertySource} having the given name
|
||||
* and backed by the given source object.
|
||||
*/
|
||||
public CommandLinePropertySource(String name, T source) {
|
||||
super(name, source);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify the name of the special "non-option arguments" property. The default is
|
||||
* {@value #DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME}.
|
||||
* Specify the name of the special "non-option arguments" property.
|
||||
* The default is {@value #DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME}.
|
||||
*/
|
||||
public void setNonOptionArgsPropertyName(String nonOptionArgsPropertyName) {
|
||||
this.nonOptionArgsPropertyName = nonOptionArgsPropertyName;
|
||||
@@ -265,6 +268,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return whether the set of option arguments parsed from the command line contains
|
||||
* an option with the given name.
|
||||
|
||||
@@ -44,10 +44,11 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* See {@link CommandLinePropertySource} for complete general usage examples.
|
||||
*
|
||||
* <p>Requires JOpt version 3.0 or higher. Tested against JOpt up until 4.6.
|
||||
* <p>Requires JOpt version 4.3 or higher. Tested against JOpt up until 4.6.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
* @author Dave Syer
|
||||
* @since 3.1
|
||||
* @see CommandLinePropertySource
|
||||
* @see joptsimple.OptionParser
|
||||
@@ -82,11 +83,11 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySource<Opt
|
||||
@Override
|
||||
public String[] getPropertyNames() {
|
||||
List<String> names = new ArrayList<String>();
|
||||
for (OptionSpec<?> spec : source.specs()) {
|
||||
for (OptionSpec<?> spec : this.source.specs()) {
|
||||
List<String> aliases = new ArrayList<String>(spec.options());
|
||||
if (!aliases.isEmpty()) {
|
||||
// Only the longest name is used for enumerating
|
||||
names.add(aliases.get(aliases.size()-1));
|
||||
names.add(aliases.get(aliases.size() - 1));
|
||||
}
|
||||
}
|
||||
return names.toArray(new String[names.size()]);
|
||||
|
||||
Reference in New Issue
Block a user