Class Option.Builder
- java.lang.Object
-
- com.aspectran.shell.command.option.Option.Builder
-
- Enclosing class:
- Option
public static final class Option.Builder extends java.lang.ObjectA nested builder class to createOptioninstances using descriptive methods.Example usage:
Option option = Option.builder("a") .required(true) .longName("arg-name") .build();
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optionbuild()Constructs an Option with the values declared by thisOption.Builder.Option.Builderdesc(java.lang.String description)Sets the description for this option.Option.BuilderhasValue()Indicates that the Option will require an argument.Option.BuilderhasValue(boolean hasValue)Indicates if the Option has an argument value or not.Option.BuilderhasValues()Indicates that the Option can have unlimited argument values.Option.BuilderlongName(java.lang.String longName)Sets the long name of the Option.Option.BuildernumberOfValues(int numberOfValues)Sets the number of argument values the Option can take.Option.BuilderoptionalValue()Sets whether the Option can have an optional argument value.Option.Builderrequired()Marks this Option as required.Option.Builderrequired(boolean required)Sets whether the Option is mandatory.Option.BuildervalueName(java.lang.String valueName)Sets the display name for the argument value.Option.BuildervalueType(OptionValueType valueType)Sets the type of the Option.Option.BuilderwithEqualSign()The Option will use '=' as a means to separate argument value.
-
-
-
Method Detail
-
longName
public Option.Builder longName(java.lang.String longName)
Sets the long name of the Option.- Parameters:
longName- the long name of the Option- Returns:
- this builder, to allow method chaining
-
valueName
public Option.Builder valueName(java.lang.String 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
public Option.Builder valueType(OptionValueType valueType)
Sets the type of the Option.- Parameters:
valueType- the type of the Option- Returns:
- this builder, to allow method chaining
-
withEqualSign
public Option.Builder withEqualSign()
The Option will use '=' as a means to separate argument value.- Returns:
- this builder, to allow method chaining
-
hasValue
public Option.Builder hasValue()
Indicates that the Option will require an argument.- Returns:
- this builder, to allow method chaining
-
hasValue
public Option.Builder hasValue(boolean 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
public Option.Builder hasValues()
Indicates that the Option can have unlimited argument values.- Returns:
- this builder, to allow method chaining
-
numberOfValues
public Option.Builder numberOfValues(int 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
public Option.Builder optionalValue()
Sets whether the Option can have an optional argument value.- Returns:
- this builder, to allow method chaining
-
required
public Option.Builder required()
Marks this Option as required.- Returns:
- this builder, to allow method chaining
-
required
public Option.Builder required(boolean required)
Sets whether the Option is mandatory.- Parameters:
required- specifies whether the Option is mandatory- Returns:
- this builder, to allow method chaining
-
desc
public Option.Builder desc(java.lang.String description)
Sets the description for this option.- Parameters:
description- the description of the option- Returns:
- this builder, to allow method chaining
-
build
public Option build()
Constructs an Option with the values declared by thisOption.Builder.- Returns:
- the new
Option - Throws:
java.lang.IllegalArgumentException- if neithernameorlongNamehas been set
-
-