Package org.apache.commons.cli.help
Class OptionFormatter.Builder
- java.lang.Object
-
- org.apache.commons.cli.help.OptionFormatter.Builder
-
- All Implemented Interfaces:
java.util.function.Supplier<OptionFormatter>
- Enclosing class:
- OptionFormatter
public static final class OptionFormatter.Builder extends java.lang.Object implements java.util.function.Supplier<OptionFormatter>
Builds instances ofOptionFormatter.
-
-
Constructor Summary
Constructors Constructor Description Builder(OptionFormatter optionFormatter)Constructor that takes the arguments from the suppliedOptionFormatter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OptionFormatterbuild(Option option)Build an OptionFormatter to format the specified option.OptionFormatterget()OptionFormatter.BuildersetArgumentNameDelimiters(java.lang.String begin, java.lang.String end)Specifies the starting and ending argument name delimiters forOptioninstances.OptionFormatter.BuildersetDefaultArgName(java.lang.String name)Sets the default argument name.OptionFormatter.BuildersetDeprecatedFormatFunction(java.util.function.Function<Option,java.lang.String> deprecatedFormatFunction)Specifies the function to construct the deprecated massage for the Option.OptionFormatter.BuildersetLongOptPrefix(java.lang.String prefix)Sets the long option prefix.OptionFormatter.BuildersetOptArgSeparator(java.lang.String optArgSeparator)Sets the separator displayed between a options and the argument name.OptionFormatter.BuildersetOptionalDelimiters(java.lang.String begin, java.lang.String end)Specifies the starting and ending delimiters for optionalOptioninstances.OptionFormatter.BuildersetOptPrefix(java.lang.String optPrefix)Specifies the short option prefix.OptionFormatter.BuildersetOptSeparator(java.lang.String optSeparator)Sets the separator displayed between a long option and short options.OptionFormatter.BuildersetSyntaxFormatFunction(java.util.function.BiFunction<OptionFormatter,java.lang.Boolean,java.lang.String> syntaxFormatFunction)Specifies the function to convert anOptionFormatterinto the syntax format for the option.java.lang.StringtoArgName(java.lang.String argName)A helper method to format any string as an argument name based on this builder.
-
-
-
Constructor Detail
-
Builder
public Builder(OptionFormatter optionFormatter)
Constructor that takes the arguments from the suppliedOptionFormatter- Parameters:
optionFormatter- The option formatter to provide values for the builder.
-
-
Method Detail
-
build
public OptionFormatter build(Option option)
Build an OptionFormatter to format the specified option.- Parameters:
option- The Option to format.- Returns:
- An OptionFormatter to format the specified option.
-
get
public OptionFormatter get()
- Specified by:
getin interfacejava.util.function.Supplier<OptionFormatter>
-
setArgumentNameDelimiters
public OptionFormatter.Builder setArgumentNameDelimiters(java.lang.String begin, java.lang.String end)
Specifies the starting and ending argument name delimiters forOptioninstances.- Parameters:
begin- the beginning delimiter.end- the ending delimiter.- Returns:
- this instance.
-
setDefaultArgName
public OptionFormatter.Builder setDefaultArgName(java.lang.String name)
Sets the default argument name.- Parameters:
name- the new value of default argument name.- Returns:
- this
-
setDeprecatedFormatFunction
public OptionFormatter.Builder setDeprecatedFormatFunction(java.util.function.Function<Option,java.lang.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
public OptionFormatter.Builder setLongOptPrefix(java.lang.String prefix)
Sets the long option prefix.- Parameters:
prefix- prefix for long options.- Returns:
- this
-
setOptArgSeparator
public OptionFormatter.Builder setOptArgSeparator(java.lang.String optArgSeparator)
Sets the separator displayed between a options and the argument name. Typically ' ' or '='.- Parameters:
optArgSeparator- the separator.- Returns:
- this
- Since:
- 1.3
-
setOptionalDelimiters
public OptionFormatter.Builder setOptionalDelimiters(java.lang.String begin, java.lang.String end)
Specifies the starting and ending delimiters for optionalOptioninstances.- Parameters:
begin- the beginning delimiter.end- the ending delimiter.- Returns:
- this instance.
-
setOptPrefix
public OptionFormatter.Builder setOptPrefix(java.lang.String optPrefix)
Specifies the short option prefix.- Parameters:
optPrefix- the prefix for short options.- Returns:
- this instance.
-
setOptSeparator
public OptionFormatter.Builder setOptSeparator(java.lang.String optSeparator)
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(java.util.function.BiFunction<OptionFormatter,java.lang.Boolean,java.lang.String> syntaxFormatFunction)
Specifies the function to convert anOptionFormatterinto the syntax format for the option.- Parameters:
syntaxFormatFunction- The function to convert anOptionFormatterinto the syntax format for the option.- Returns:
- this
-
toArgName
public java.lang.String toArgName(java.lang.String argName)
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.
-
-