Class DefaultParser.Builder
- All Implemented Interfaces:
Supplier<DefaultParser>
- Enclosing class:
DefaultParser
DefaultParser instances
using descriptive methods.
Example usage:
DefaultParser parser = Option.builder()
.setAllowPartialMatching(false)
.setStripLeadingAndTrailingQuotes(false)
.build();
- Since:
- 1.5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanFlag indicating if partial matching of long options is supported.The deprecated option handler.private BooleanFlag indicating if balanced leading and trailing double quotes should be stripped from option arguments. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateBuilder()Constructs a newBuilderfor aDefaultParserinstance. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Deprecated.get()Builds an DefaultParser with the values declared by thisDefaultParser.Builder.setAllowPartialMatching(boolean allowPartialMatching) Sets if partial matching of long options is supported.setDeprecatedHandler(Consumer<Option> deprecatedHandler) Sets the deprecated option handler.setStripLeadingAndTrailingQuotes(Boolean stripLeadingAndTrailingQuotes) Sets if balanced leading and trailing double quotes should be stripped from option arguments.
-
Field Details
-
allowPartialMatching
private boolean allowPartialMatchingFlag indicating if partial matching of long options is supported. -
deprecatedHandler
The deprecated option handler.If you want to serialize this field, use a serialization proxy.
-
stripLeadingAndTrailingQuotes
Flag indicating if balanced leading and trailing double quotes should be stripped from option arguments.
-
-
Constructor Details
-
Builder
private Builder()Constructs a newBuilderfor aDefaultParserinstance.Both allowPartialMatching and stripLeadingAndTrailingQuotes are true by default, mimicking the argument-less constructor.
-
-
Method Details
-
build
Deprecated.Useget().Builds an DefaultParser with the values declared by thisDefaultParser.Builder.- Returns:
- the new
DefaultParser. - Since:
- 1.5.0
-
get
Builds an DefaultParser with the values declared by thisDefaultParser.Builder.- Specified by:
getin interfaceSupplier<DefaultParser>- Returns:
- the new
DefaultParser. - Since:
- 1.10.0
-
setAllowPartialMatching
Sets if partial matching of long options is supported.By "partial matching" we mean that given the following code:
final Options options = new Options(); options.addOption(new Option("d", "debug", false, "Turn on debug.")); options.addOption(new Option("e", "extract", false, "Turn on extract.")); options.addOption(new Option("o", "option", true, "Turn on option with argument."));If "partial matching" is turned on,
-deonly matches the"debug"option. However, with "partial matching" disabled,-dewould enable bothdebugas well asextract- Parameters:
allowPartialMatching- whether to allow partial matching of long options.- Returns:
thisinstance.- Since:
- 1.5.0
-
setDeprecatedHandler
Sets the deprecated option handler.- Parameters:
deprecatedHandler- the deprecated option handler.- Returns:
thisinstance.- Since:
- 1.7.0
-
setStripLeadingAndTrailingQuotes
public DefaultParser.Builder setStripLeadingAndTrailingQuotes(Boolean stripLeadingAndTrailingQuotes) Sets if balanced leading and trailing double quotes should be stripped from option arguments.If "stripping of balanced leading and trailing double quotes from option arguments" is true, the outermost balanced double quotes of option arguments values will be removed. For example,
-o '"x"'getValue() will returnx, instead of"x"If "stripping of balanced leading and trailing double quotes from option arguments" is null, then quotes will be stripped from option values separated by space from the option, but kept in other cases, which is the historic behavior.
- Parameters:
stripLeadingAndTrailingQuotes- whether balanced leading and trailing double quotes should be stripped from option arguments.- Returns:
thisinstance.- Since:
- 1.5.0
-
get().