Package com.gengoai.application
Class NamedOption
- java.lang.Object
-
- com.gengoai.application.NamedOption
-
public final class NamedOption extends Object
Represents an named command line option. The command line specification is determined by the name and type of the option.
- Name is a single character and is boolean: Short form
-n
- Name is a multiple characters: long form
--n
NamedOption
s can be built either by passing aField
containing anOption
annotation or by using the builder.Three options are predefined and are automatically added to every command line parser:
HELP
: Shows help if-h
or--help
is given.CONFIG
: Specifies a configuration resource to load when--config
is given.DUMP_CONFIG
: Shows how the current configuration was created with the lineage of each property when--config-explain
is given.
- Author:
- David B. Bracewell
- Name is a single character and is boolean: Short form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NamedOption.NamedOptionBuilder
Builder class to create a named options
-
Field Summary
Fields Modifier and Type Field Description static NamedOption
CONFIG
Specifies a configuration resource to load when--config
is given.static NamedOption
DUMP_CONFIG
Shows how the current configuration was created with the lineage of each property when--config-explain
is given.static NamedOption
HELP
Shows help if-h
or--help
is given.
-
Constructor Summary
Constructors Constructor Description NamedOption(RField field)
Instantiates a new Named option.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NamedOption.NamedOptionBuilder
builder()
Gets a builder for NamedOptionsString[]
getAliasSpecifications()
Converts the aliases into a specification forms, e.g.String
getSpecification()
Gets specification form for the command line.<T> T
getValue()
Gets the value of the option.boolean
isBoolean()
Determines if the option is a boolean type or not
-
-
-
Field Detail
-
HELP
public static final NamedOption HELP
Shows help if-h
or--help
is given.
-
CONFIG
public static final NamedOption CONFIG
Specifies a configuration resource to load when--config
is given.
-
DUMP_CONFIG
public static final NamedOption DUMP_CONFIG
Shows how the current configuration was created with the lineage of each property when--config-explain
is given.
-
-
Method Detail
-
builder
public static NamedOption.NamedOptionBuilder builder()
Gets a builder for NamedOptions- Returns:
- the named option builder
-
getAliasSpecifications
public String[] getAliasSpecifications()
Converts the aliases into a specification forms, e.g. with "-" or "--" added.- Returns:
- the alias specifications
-
getSpecification
public String getSpecification()
Gets specification form for the command line.- Returns:
- the specification form for the command line
-
getValue
public <T> T getValue()
Gets the value of the option.- Type Parameters:
T
- the type parameter- Returns:
- the value op the option
-
isBoolean
public boolean isBoolean()
Determines if the option is a boolean type or not- Returns:
- True if the option is a boolean type, False otherwise
-
-