# Class DefaultParser.Builder

java.lang.Object
org.apache.commons.cli.DefaultParser.Builder

All Implemented Interfaces:
  `Supplier<DefaultParser>`

Enclosing class:
  `DefaultParser`

public static final class DefaultParser.Builder extends Object implements Supplier<DefaultParser>
A nested builder class to create `DefaultParser` instances using descriptive methods. Example usage:

    DefaultParser parser = Option.builder()
        .setAllowPartialMatching(false)
        .setStripLeadingAndTrailingQuotes(false)
        .build();

Since:
  1.5.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `DefaultParser`
  `build()`
  Deprecated.
  Use `get()`.
  `DefaultParser`
  `get()`
  Builds an DefaultParser with the values declared by this `DefaultParser.Builder`.
  `DefaultParser.Builder`
  `setAllowPartialMatching(boolean allowPartialMatching)`
  Sets if partial matching of long options is supported.
  `DefaultParser.Builder`
  `setDeprecatedHandler(Consumer<Option> deprecatedHandler)`
  Sets the deprecated option handler.
  `DefaultParser.Builder`
  `setStripLeadingAndTrailingQuotes(Boolean stripLeadingAndTrailingQuotes)`
  Sets if balanced leading and trailing double quotes should be stripped from option arguments.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### build

    @Deprecated public DefaultParser build()
    Deprecated.
    Use `get()`.
    Builds an DefaultParser with the values declared by this `DefaultParser.Builder`.
    Returns:
      the new `DefaultParser`.
    Since:
      1.5.0

  - ### get

    public DefaultParser get()
    Builds an DefaultParser with the values declared by this `DefaultParser.Builder`.
    Specified by:
      `get` in interface `Supplier<DefaultParser>`
    Returns:
      the new `DefaultParser`.
    Since:
      1.10.0

  - ### setAllowPartialMatching

    public DefaultParser.Builder setAllowPartialMatching(boolean allowPartialMatching)
    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, `-de` only matches the `"debug"` option. However, with "partial matching" disabled, `-de` would enable both `debug` as well as `extract`

    Parameters:
      `allowPartialMatching` - whether to allow partial matching of long options.
    Returns:
      `this` instance.
    Since:
      1.5.0

  - ### setDeprecatedHandler

    public DefaultParser.Builder setDeprecatedHandler(Consumer<Option> deprecatedHandler)
    Sets the deprecated option handler.
    Parameters:
      `deprecatedHandler` - the deprecated option handler.
    Returns:
      `this` instance.
    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 return `x`, 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:
      `this` instance.
    Since:
      1.5.0