joptsimple
Class OptionSpecBuilder

java.lang.Object
  extended by joptsimple.OptionSpecBuilder

public class OptionSpecBuilder
extends java.lang.Object

Wraps an option specification, and allows callers to specify whether the option accepts arguments (required or optional).

Instances are returned from OptionParser.accepts(String) to allow the formation of parser directives as sentences in a domain-specific 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.

Since:
2.0
Version:
$Id: OptionSpecBuilder.java,v 1.2 2008/04/08 03:20:17 pholser Exp $
Author:
Paul Holser

Field Summary
private  java.lang.String description
           
private  java.util.List options
           
private  OptionParser parser
           
 
Constructor Summary
OptionSpecBuilder(OptionParser parser, java.util.List options, java.lang.String description)
           
 
Method Summary
 ArgumentAcceptingOptionSpec withOptionalArg()
          Informs an option parser that this builder's option accepts an optional argument.
 ArgumentAcceptingOptionSpec withRequiredArg()
          Informs an option parser that this builder's option requires an argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

private final OptionParser parser

options

private final java.util.List options

description

private final java.lang.String description
Constructor Detail

OptionSpecBuilder

OptionSpecBuilder(OptionParser parser,
                  java.util.List options,
                  java.lang.String description)
Method Detail

withRequiredArg

public ArgumentAcceptingOptionSpec withRequiredArg()

Informs an option parser that this builder's option requires an argument.

Returns:
a specification for the option

withOptionalArg

public ArgumentAcceptingOptionSpec withOptionalArg()

Informs an option parser that this builder's option accepts an optional argument.

Returns:
a specification for the option