Package joptsimple
Class AbstractOptionSpec<V>
- java.lang.Object
-
- joptsimple.AbstractOptionSpec<V>
-
- Type Parameters:
V- represents the type of the arguments this option accepts
- All Implemented Interfaces:
OptionDescriptor,OptionSpec<V>
- Direct Known Subclasses:
ArgumentAcceptingOptionSpec,NoArgumentOptionSpec,NonOptionArgumentSpec
public abstract class AbstractOptionSpec<V> extends java.lang.Object implements OptionSpec<V>, OptionDescriptor
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringdescriptionprivate booleanforHelpprivate java.util.List<java.lang.String>options
-
Constructor Summary
Constructors Constructor Description AbstractOptionSpec(java.lang.String option)AbstractOptionSpec(java.util.List<java.lang.String> options, java.lang.String description)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringargumentTypeIndicatorFrom(ValueConverter<V> converter)private voidarrangeOptions(java.util.List<java.lang.String> unarranged)protected abstract Vconvert(java.lang.String argument)protected VconvertWith(ValueConverter<V> converter, java.lang.String argument)java.lang.Stringdescription()Description of this option's purpose.booleanequals(java.lang.Object that)AbstractOptionSpec<V>forHelp()(package private) abstract voidhandleOption(OptionParser parser, ArgumentList arguments, OptionSet detectedOptions, java.lang.String detectedArgument)inthashCode()booleanisForHelp()Tells whether this option is designated as a "help" option.java.util.List<java.lang.String>options()A set of options that are mutually synonymous.booleanrepresentsNonOptions()Tells whether this object represents the non-option arguments of a command line.java.lang.StringtoString()Vvalue(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.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface joptsimple.OptionDescriptor
acceptsArguments, argumentDescription, argumentTypeIndicator, defaultValues, isRequired, requiresArgument
-
-
-
-
Method Detail
-
options
public final java.util.List<java.lang.String> options()
Description copied from interface:OptionDescriptorA set of options that are mutually synonymous.- Specified by:
optionsin interfaceOptionDescriptor- Specified by:
optionsin interfaceOptionSpec<V>- Returns:
- the string representations of this option
-
values
public final java.util.List<V> values(OptionSet detectedOptions)
Description copied from interface:OptionSpecGives any arguments associated with the given option in the given set of detected options.Specifying a default argument value for this option will cause this method to return that default value even if this option was not detected on the command line, or if this option can take an optional argument but did not have one on the command line.
- Specified by:
valuesin interfaceOptionSpec<V>- Parameters:
detectedOptions- the detected options to search in- Returns:
- the arguments associated with this option; an empty list if no such arguments are present, or if this option was not detected
- See Also:
OptionSet.valuesOf(OptionSpec)
-
value
public final V value(OptionSet detectedOptions)
Description copied from interface:OptionSpecGives the argument associated with the given option in the given set of detected options.Specifying a default argument value for this option will cause this method to return that default value even if this option was not detected on the command line, or if this option can take an optional argument but did not have one on the command line.
- Specified by:
valuein interfaceOptionSpec<V>- Parameters:
detectedOptions- the detected options to search in- Returns:
- the argument of the this option;
nullif no argument is present, or that option was not detected - See Also:
OptionSet.valueOf(OptionSpec)
-
description
public java.lang.String description()
Description copied from interface:OptionDescriptorDescription of this option's purpose.- Specified by:
descriptionin interfaceOptionDescriptor- Returns:
- a description for the option
-
forHelp
public final AbstractOptionSpec<V> forHelp()
-
isForHelp
public final boolean isForHelp()
Description copied from interface:OptionSpecTells whether this option is designated as a "help" option. The presence of a "help" option on a command line means that missing "required" options will not cause parsing to fail.- Specified by:
isForHelpin interfaceOptionSpec<V>- Returns:
- whether this option is designated as a "help" option
-
representsNonOptions
public boolean representsNonOptions()
Description copied from interface:OptionDescriptorTells whether this object represents the non-option arguments of a command line.- Specified by:
representsNonOptionsin interfaceOptionDescriptor- Returns:
trueif this represents non-option arguments
-
convert
protected abstract V convert(java.lang.String argument)
-
convertWith
protected V convertWith(ValueConverter<V> converter, java.lang.String argument)
-
argumentTypeIndicatorFrom
protected java.lang.String argumentTypeIndicatorFrom(ValueConverter<V> converter)
-
handleOption
abstract void handleOption(OptionParser parser, ArgumentList arguments, OptionSet detectedOptions, java.lang.String detectedArgument)
-
arrangeOptions
private void arrangeOptions(java.util.List<java.lang.String> unarranged)
-
equals
public boolean equals(java.lang.Object that)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-