joptsimple
V
- represents the type of the arguments this option acceptspublic interface OptionSpec<V>
Describes options that an option parser recognizes.
Instances of this interface are returned by the "fluent interface" methods to allow retrieval of option arguments in a type-safe manner. Here's an example:
OptionParser parser = new OptionParser();
OptionSpec<Integer> count =
parser.accepts( "count" ).withRequiredArg().ofType( Integer.class );
OptionSet options = parser.parse( "--count", "2" );
assert options.has( count );
int countValue = options.valueOf( count );
assert countValue == count.value( options );
List<Integer> countValues = options.valuesOf( count );
assert countValues.equals( count.values( options ) );
Modifier and Type | Method and Description |
---|---|
java.util.Collection<java.lang.String> |
options() |
V |
value(OptionSet detectedOptions)
Gives the argument associated with the given option in the given set of
detected options.
|
java.util.List<V> |
values(OptionSet detectedOptions)
Gives any arguments associated with the given option in the given set of
detected options.
|
java.util.List<V> values(OptionSet detectedOptions)
Gives any arguments associated with the given option in the given set of detected options.
detectedOptions
- the detected options to search inOptionException
- if there is a problem converting this option's arguments
to the desired type; for example, if the type does not implement a correct
conversion constructor or methodjava.lang.NullPointerException
- if detectedOptions
is null
V value(OptionSet detectedOptions)
Gives the argument associated with the given option in the given set of detected options.
detectedOptions
- the detected options to search innull
if no argument is present,
or that option was not detectedOptionException
- if more than one argument was detected for the optionjava.lang.NullPointerException
- if detectedOptions
is null
java.lang.ClassCastException
- if the arguments of this option are not of the
expected typejava.util.Collection<java.lang.String> options()