Package org.apache.commons.cli.help
Class OptionFormatter.Builder
java.lang.Object
org.apache.commons.cli.help.OptionFormatter.Builder
- All Implemented Interfaces:
Supplier<OptionFormatter>
- Enclosing class:
OptionFormatter
public static final class OptionFormatter.Builder
extends Object
implements Supplier<OptionFormatter>
Builds instances of
OptionFormatter
.-
Constructor Summary
ConstructorsConstructorDescriptionBuilder
(OptionFormatter optionFormatter) Constructor that takes the arguments from the suppliedOptionFormatter
-
Method Summary
Modifier and TypeMethodDescriptionBuild an OptionFormatter to format the specified option.get()
setArgumentNameDelimiters
(String begin, String end) Specifies the starting and ending argument name delimiters forOption
instances.setDefaultArgName
(String name) Sets the default argument name.setDeprecatedFormatFunction
(Function<Option, String> deprecatedFormatFunction) Specifies the function to construct the deprecated massage for the Option.setLongOptPrefix
(String prefix) Sets the long option prefix.setOptArgSeparator
(String optArgSeparator) Sets the separator displayed between a options and the argument name.setOptionalDelimiters
(String begin, String end) Specifies the starting and ending delimiters for optionalOption
instances.setOptPrefix
(String optPrefix) Specifies the short option prefix.setOptSeparator
(String optSeparator) Sets the separator displayed between a long option and short options.setSyntaxFormatFunction
(BiFunction<OptionFormatter, Boolean, String> syntaxFormatFunction) Specifies the function to convert anOptionFormatter
into the syntax format for the option.A helper method to format any string as an argument name based on this builder.
-
Constructor Details
-
Builder
Constructor that takes the arguments from the suppliedOptionFormatter
- Parameters:
optionFormatter
- The option formatter to provide values for the builder.
-
-
Method Details
-
build
Build an OptionFormatter to format the specified option.- Parameters:
option
- The Option to format.- Returns:
- An OptionFormatter to format the specified option.
-
get
- Specified by:
get
in interfaceSupplier<OptionFormatter>
-
setArgumentNameDelimiters
Specifies the starting and ending argument name delimiters forOption
instances.- Parameters:
begin
- the beginning delimiter.end
- the ending delimiter.- Returns:
- this instance.
-
setDefaultArgName
Sets the default argument name.- Parameters:
name
- the new value of default argument name.- Returns:
- this
-
setDeprecatedFormatFunction
public OptionFormatter.Builder setDeprecatedFormatFunction(Function<Option, String> deprecatedFormatFunction) Specifies the function to construct the deprecated massage for the Option. Should include the description text if desired.- Parameters:
deprecatedFormatFunction
- the function to specify the deprecated message for the option.- Returns:
- this instance.
-
setLongOptPrefix
Sets the long option prefix.- Parameters:
prefix
- prefix for long options.- Returns:
- this
-
setOptArgSeparator
Sets the separator displayed between a options and the argument name. Typically ' ' or '='.- Parameters:
optArgSeparator
- the separator.- Returns:
- this
- Since:
- 1.3
-
setOptionalDelimiters
Specifies the starting and ending delimiters for optionalOption
instances.- Parameters:
begin
- the beginning delimiter.end
- the ending delimiter.- Returns:
- this instance.
-
setOptPrefix
Specifies the short option prefix.- Parameters:
optPrefix
- the prefix for short options.- Returns:
- this instance.
-
setOptSeparator
Sets the separator displayed between a long option and short options. Typically ',' or ' '.- Parameters:
optSeparator
- the separator.- Returns:
- this
- Since:
- 1.3
-
setSyntaxFormatFunction
public OptionFormatter.Builder setSyntaxFormatFunction(BiFunction<OptionFormatter, Boolean, String> syntaxFormatFunction) Specifies the function to convert anOptionFormatter
into the syntax format for the option.- Parameters:
syntaxFormatFunction
- The function to convert anOptionFormatter
into the syntax format for the option.- Returns:
- this
-
toArgName
A helper method to format any string as an argument name based on this builder.- Parameters:
argName
- the name of the argument.- Returns:
- the formatted argument.
-