Class Option.Builder
java.lang.Object
com.aspectran.shell.command.option.Option.Builder
- Enclosing class:
- Option
A nested builder class to create
Option
instances
using descriptive methods.
Example usage:
Option option = Option.builder("a") .required(true) .longName("arg-name") .build();
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Constructs an Option with the values declared by thisOption.Builder
.Sets the description for this option.hasValue()
Indicates that the Option will require an argument.hasValue
(boolean hasValue) Indicates if the Option has an argument value or not.Indicates that the Option can have unlimited argument values.Sets the long name of the Option.numberOfValues
(int numberOfValues) Sets the number of argument values the Option can take.Sets whether the Option can have an optional argument value.required()
Marks this Option as required.required
(boolean required) Sets whether the Option is mandatory.Sets the display name for the argument value.valueType
(OptionValueType valueType) Sets the type of the Option.The Option will use '=' as a means to separate argument value.
-
Method Details
-
longName
Sets the long name of the Option.- Parameters:
longName
- the long name of the Option- Returns:
- this builder, to allow method chaining
-
valueName
Sets the display name for the argument value.- Parameters:
valueName
- the display name for the argument value- Returns:
- this builder, to allow method chaining
-
valueType
Sets the type of the Option.- Parameters:
valueType
- the type of the Option- Returns:
- this builder, to allow method chaining
-
withEqualSign
The Option will use '=' as a means to separate argument value.- Returns:
- this builder, to allow method chaining
-
hasValue
Indicates that the Option will require an argument.- Returns:
- this builder, to allow method chaining
-
hasValue
Indicates if the Option has an argument value or not.- Parameters:
hasValue
- specifies whether the Option takes an argument value or not- Returns:
- this builder, to allow method chaining
-
hasValues
Indicates that the Option can have unlimited argument values.- Returns:
- this builder, to allow method chaining
-
numberOfValues
Sets the number of argument values the Option can take.- Parameters:
numberOfValues
- the number of argument values- Returns:
- this builder, to allow method chaining
-
optionalValue
Sets whether the Option can have an optional argument value.- Returns:
- this builder, to allow method chaining
-
required
Marks this Option as required.- Returns:
- this builder, to allow method chaining
-
required
Sets whether the Option is mandatory.- Parameters:
required
- specifies whether the Option is mandatory- Returns:
- this builder, to allow method chaining
-
desc
Sets the description for this option.- Parameters:
description
- the description of the option- Returns:
- this builder, to allow method chaining
-
build
Constructs an Option with the values declared by thisOption.Builder
.- Returns:
- the new
Option
- Throws:
IllegalArgumentException
- if neithername
orlongName
has been set
-