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
| Modifier and Type | Field and Description |
|---|---|
| private final OptionParser |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public OptionSpecBuilder | Returns: self, so that the caller can add clauses to the fluent interface sentencean option whose presence on a command line makes this builder's option allowed dependent, String... other options whose presence on a command line makes this builder's option allowed otherDependents)Informs an option parser that this builder's option is allowed if the given option is present on the command line. |
| public OptionSpecBuilder | Returns: self, so that the caller can add clauses to the fluent interface sentencethe option whose presence on a command line makes this builder's option allowed dependent, OptionSpec<?>... other options whose presence on a command line makes this builder's option allowed otherDependents)Informs an option parser that this builder's option is allowed if the given option is present on the command line. |
| public OptionSpecBuilder | Returns: self, so that the caller can add clauses to the fluent interface sentencean option whose absence on a command line makes this builder's option allowed dependent, String... other options whose absence on a command line makes this builder's option allowed otherDependents)Informs an option parser that this builder's option is allowed if the given option is absent on the command line. |
| public OptionSpecBuilder | Returns: self, so that the caller can add clauses to the fluent interface sentencethe option whose absence on a command line makes this builder's option allowed dependent, OptionSpec<?>... other options whose absence on a command line makes this builder's option allowed otherDependents)Informs an option parser that this builder's option is allowed if the given option is absent on the command line. |
| public OptionSpecBuilder | Returns: self, so that the caller can add clauses to the fluent interface sentencean option whose presence on a command line makes this builder's option required dependent, String... other options whose presence on a command line makes this builder's option required otherDependents)Informs an option parser that this builder's option is required if the given option is present on the command line. |
| public OptionSpecBuilder | Returns: self, so that the caller can add clauses to the fluent interface sentencethe option whose presence on a command line makes this builder's option required dependent, OptionSpec<?>... other options whose presence on a command line makes this builder's option required otherDependents)Informs an option parser that this builder's option is required if the given option is present on the command line. |
| public OptionSpecBuilder | Returns: self, so that the caller can add clauses to the fluent interface sentencean option whose absence on a command line makes this builder's option required dependent, String... other options whose absence on a command line makes this builder's option required otherDependents)Informs an option parser that this builder's option is required if the given option is absent on the command line. |
| public OptionSpecBuilder | Returns: self, so that the caller can add clauses to the fluent interface sentencethe option whose absence on a command line makes this builder's option required dependent, OptionSpec<?>... other options whose absence on a command line makes this builder's option required otherDependents)Informs an option parser that this builder's option is required if the given option is absent on the command line. |
| private List | |
| public ArgumentAcceptingOptionSpec | Returns: a specification for the optionInforms an option parser that this builder's option accepts an optional argument. |
| public ArgumentAcceptingOptionSpec | Returns: a specification for the optionInforms an option parser that this builder's option requires an argument. |
| parser | back to summary |
|---|---|
| private final OptionParser parser | |
| OptionSpecBuilder | back to summary |
|---|---|
| pack-priv OptionSpecBuilder(OptionParser parser, List<String> options, String description) | |
| attachToParser | back to summary |
|---|---|
| private void attachToParser() | |
| availableIf | back to summary |
|---|---|
| public OptionSpecBuilder availableIf(String dependent, String... otherDependents) Informs an option parser that this builder's option is allowed if the given option is present on the command line. For a given option, you should not mix this with
| |
| availableIf | back to summary |
|---|---|
| public OptionSpecBuilder availableIf(OptionSpec<?> dependent, OptionSpec<?>... otherDependents) Informs an option parser that this builder's option is allowed if the given option is present on the command line. For a given option, you should not mix this with This method recognizes only instances of options returned from the fluent interface methods.
| |
| availableUnless | back to summary |
|---|---|
| public OptionSpecBuilder availableUnless(String dependent, String... otherDependents) Informs an option parser that this builder's option is allowed if the given option is absent on the command line. For a given option, you should not mix this with
| |
| availableUnless | back to summary |
|---|---|
| public OptionSpecBuilder availableUnless(OptionSpec<?> dependent, OptionSpec<?>... otherDependents) Informs an option parser that this builder's option is allowed if the given option is absent on the command line. For a given option, you should not mix this with This method recognizes only instances of options returned from the fluent interface methods.
| |
| requiredIf | back to summary |
|---|---|
| public OptionSpecBuilder requiredIf(String dependent, String... otherDependents) Informs an option parser that this builder's option is required if the given option is present on the command line. For a given option, you should not mix this with
| |
| requiredIf | back to summary |
|---|---|
| public OptionSpecBuilder requiredIf(OptionSpec<?> dependent, OptionSpec<?>... otherDependents) Informs an option parser that this builder's option is required if the given option is present on the command line. For a given option, you should not mix this with This method recognizes only instances of options returned from the fluent interface methods.
| |
| requiredUnless | back to summary |
|---|---|
| public OptionSpecBuilder requiredUnless(String dependent, String... otherDependents) Informs an option parser that this builder's option is required if the given option is absent on the command line. For a given option, you should not mix this with
| |
| requiredUnless | back to summary |
|---|---|
| public OptionSpecBuilder requiredUnless(OptionSpec<?> dependent, OptionSpec<?>... otherDependents) Informs an option parser that this builder's option is required if the given option is absent on the command line. For a given option, you should not mix this with This method recognizes only instances of options returned from the fluent interface methods.
| |
| validatedDependents | back to summary |
|---|---|
| private List | |
| withOptionalArg | back to summary |
|---|---|
| public ArgumentAcceptingOptionSpec Informs an option parser that this builder's option accepts an optional argument.
| |
| withRequiredArg | back to summary |
|---|---|
| public ArgumentAcceptingOptionSpec Informs an option parser that this builder's option requires an argument.
| |