Package org.springframework.boot
Class DefaultApplicationArguments
- java.lang.Object
- org.springframework.boot.DefaultApplicationArguments
- All Implemented Interfaces:
ApplicationArguments
public class DefaultApplicationArguments extends Object implements ApplicationArguments
Default implementation ofApplicationArguments
.- Since:
- 1.4.1
Constructor Summary
Constructors Constructor Description DefaultApplicationArguments(String[] args)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsOption(String name)
Return whether the set of option arguments parsed from the arguments contains an option with the given name.List<String>
getNonOptionArgs()
Return the collection of non-option arguments parsed.Set<String>
getOptionNames()
Return the names of all option arguments.List<String>
getOptionValues(String name)
Return the collection of values associated with the arguments option having the given name.String[]
getSourceArgs()
Return the raw unprocessed arguments that were passed to the application.
Constructor Detail
DefaultApplicationArguments
public DefaultApplicationArguments(String[] args)
Method Detail
getSourceArgs
public String[] getSourceArgs()
Description copied from interface:ApplicationArguments
Return the raw unprocessed arguments that were passed to the application.- Specified by:
getSourceArgs
in interfaceApplicationArguments
- Returns:
- the arguments
getOptionNames
public Set<String> getOptionNames()
Description copied from interface:ApplicationArguments
Return the names of all option arguments. For example, if the arguments were "--foo=bar --debug" would return the values["foo", "debug"]
.- Specified by:
getOptionNames
in interfaceApplicationArguments
- Returns:
- the option names or an empty set
containsOption
public boolean containsOption(String name)
Description copied from interface:ApplicationArguments
Return whether the set of option arguments parsed from the arguments contains an option with the given name.- Specified by:
containsOption
in interfaceApplicationArguments
- Parameters:
name
- the name to check- Returns:
true
if the arguments contain an option with the given name
getOptionValues
public List<String> getOptionValues(String name)
Description copied from interface:ApplicationArguments
Return the collection of values associated with the arguments option having the given name.- if the option is present and has no argument (e.g.: "--foo"), return an empty collection (
[]
) - if the option is present and has a single value (e.g. "--foo=bar"), return a collection having one element (
["bar"]
) - if the option is present and has multiple values (e.g. "--foo=bar --foo=baz"), return a collection having elements for each value (
["bar", "baz"]
) - if the option is not present, return
null
- Specified by:
getOptionValues
in interfaceApplicationArguments
- Parameters:
name
- the name of the option- Returns:
- a list of option values for the given name
- if the option is present and has no argument (e.g.: "--foo"), return an empty collection (
getNonOptionArgs
public List<String> getNonOptionArgs()
Description copied from interface:ApplicationArguments
Return the collection of non-option arguments parsed.- Specified by:
getNonOptionArgs
in interfaceApplicationArguments
- Returns:
- the non-option arguments or an empty list