V
- represents the type of the non-option argumentspublic class NonOptionArgumentSpec<V> extends AbstractOptionSpec<V>
Specification of a command line's non-option arguments.
Instances are returned from OptionParser
methods to allow the formation of parser directives as
sentences in a "fluent interface" language. For example:
OptionParser parser = new OptionParser();
parser.nonOptions( "files to be processed" ).ofType( File.class );
If no methods are invoked on an instance of this class, then that instance's option will treat the non-option
arguments as String
s.
Modifier and Type | Method and Description |
---|---|
boolean |
acceptsArguments()
Does this option accept arguments?
|
Optional<ValueConverter<?>> |
argumentConverter()
Gives an object that can convert raw string values into objects of the
type of this option's argument
|
String |
argumentDescription()
Gives a short description of the option's argument.
|
String |
argumentTypeIndicator()
Gives an indication of the expected type of the option's
argument.
|
List<?> |
defaultValues()
What values will the option take if none are specified on the command line?
|
NonOptionArgumentSpec<V> |
describedAs(String description)
Specifies a description for the non-option arguments that this spec represents.
|
boolean |
isRequired()
Is this option required on a command line?
|
<T> NonOptionArgumentSpec<T> |
ofType(Class<T> argumentType)
Specifies a type to which the non-option arguments are to be converted.
|
boolean |
representsNonOptions()
Tells whether this object represents the non-option arguments of a command line.
|
boolean |
requiresArgument()
Does this option require an argument?
|
<T> NonOptionArgumentSpec<T> |
withValuesConvertedBy(ValueConverter<T> aConverter)
Specifies a converter to use to translate non-option arguments into Java objects.
|
description, equals, forHelp, hashCode, isForHelp, options, toString, value, valueOptional, values
public <T> NonOptionArgumentSpec<T> ofType(Class<T> argumentType)
Specifies a type to which the non-option arguments are to be converted.
JOpt Simple accepts types that have either:
valueOf
which accepts a single argument of type String
and whose return type is the same as the class on which the method is declared. The java.lang
primitive wrapper classes have such methods.String
.This class converts arguments using those methods in that order; that is, valueOf
would be invoked
before a one-String
-arg constructor would.
Invoking this method will trump any previous calls to this method or to
withValuesConvertedBy(ValueConverter)
.
T
- represents the runtime class of the desired option argument typeargumentType
- desired type of arguments to this spec's optionNullPointerException
- if the type is null
IllegalArgumentException
- if the type does not have the standard conversion methodspublic final <T> NonOptionArgumentSpec<T> withValuesConvertedBy(ValueConverter<T> aConverter)
Specifies a converter to use to translate non-option arguments into Java objects. This is useful
when converting to types that do not have the requisite factory method or constructor for
ofType(Class)
.
Invoking this method will trump any previous calls to this method or to ofType(Class)
.
T
- represents the runtime class of the desired non-option argument typeaConverter
- the converter to useNullPointerException
- if the converter is null
public NonOptionArgumentSpec<V> describedAs(String description)
Specifies a description for the non-option arguments that this spec represents. This description is used when generating help information about the parser.
description
- describes the nature of the argument of this spec's optionpublic List<?> defaultValues()
OptionDescriptor
public boolean isRequired()
OptionDescriptor
public boolean acceptsArguments()
OptionDescriptor
public boolean requiresArgument()
OptionDescriptor
public String argumentDescription()
OptionDescriptor
public String argumentTypeIndicator()
OptionDescriptor
public boolean representsNonOptions()
OptionDescriptor
representsNonOptions
in interface OptionDescriptor
representsNonOptions
in class AbstractOptionSpec<V>
true
if this represents non-option argumentspublic Optional<ValueConverter<?>> argumentConverter()
OptionDescriptor
© Copyright 2004-2016 Paul R. Holser, Jr. All rights reserved. Licensed under The MIT License.