|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjoptsimple.AbstractOptionSpec<java.lang.Void>
joptsimple.NoArgumentOptionSpec
joptsimple.OptionSpecBuilder
public class OptionSpecBuilder
Allows callers to specify whether a given option accepts arguments (required or optional).
Instances are returned from OptionParser.accepts(String) to allow the
formation of parser directives as sentences in a "fluent interface" language. For
example:
OptionParser parser = new OptionParser();
parser.accepts( "c" ).withRequiredArg().ofType( Integer.class );
If no methods are invoked on an instance of this class, then that instance's option will accept no argument.
Note that you should not use the fluent interface clauses in a way that would defeat the typing of option arguments:
OptionParser parser = new OptionParser();
ArgumentAcceptingOptionSpec<String> optionC =
parser.accepts( "c" ).withRequiredArg();
optionC.ofType( Integer.class ); // DON'T THROW AWAY THE TYPE!
String value = parser.parse( "-c", "2" ).valueOf( optionC ); // ClassCastException
| Field Summary | |
|---|---|
private OptionParser |
parser
|
| Constructor Summary | |
|---|---|
OptionSpecBuilder(OptionParser parser,
java.util.Collection<java.lang.String> options,
java.lang.String description)
|
|
| Method Summary | |
|---|---|
ArgumentAcceptingOptionSpec<java.lang.String> |
withOptionalArg()
Informs an option parser that this builder's option accepts an optional argument. |
ArgumentAcceptingOptionSpec<java.lang.String> |
withRequiredArg()
Informs an option parser that this builder's option requires an argument. |
| Methods inherited from class joptsimple.NoArgumentOptionSpec |
|---|
accept, acceptsArguments, convert, handleOption, requiresArgument |
| Methods inherited from class joptsimple.AbstractOptionSpec |
|---|
description, equals, hashCode, options, toString, value, values |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private final OptionParser parser
| Constructor Detail |
|---|
OptionSpecBuilder(OptionParser parser,
java.util.Collection<java.lang.String> options,
java.lang.String description)
| Method Detail |
|---|
public ArgumentAcceptingOptionSpec<java.lang.String> withRequiredArg()
Informs an option parser that this builder's option requires an argument.
public ArgumentAcceptingOptionSpec<java.lang.String> withOptionalArg()
Informs an option parser that this builder's option accepts an optional argument.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||