congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
CommandLine$Model$ParserSpec.caseInsensitiveEnumValuesAllowed
Code IndexAdd Tabnine to your IDE (free)

How to use
caseInsensitiveEnumValuesAllowed
method
in
picocli.CommandLine$Model$ParserSpec

Best Java code snippets using picocli.CommandLine$Model$ParserSpec.caseInsensitiveEnumValuesAllowed (Showing top 9 results out of 315)

origin: remkop/picocli

  @SuppressWarnings("unchecked")
  public Object convert(String value) throws Exception {
    String sensitivity = "case-sensitive";
    if (commandSpec.parser().caseInsensitiveEnumValuesAllowed()) {
      String upper = value.toUpperCase();
      for (Object enumConstant : type.getEnumConstants()) {
        if (upper.equals(String.valueOf(enumConstant).toUpperCase())) { return enumConstant; }
      }
      sensitivity = "case-insensitive";
    }
    try { return Enum.valueOf((Class<Enum>) type, value); }
    catch (Exception ex) {
      Enum<?>[] constants = ((Class<Enum<?>>) type).getEnumConstants();
      String[] names = new String[constants.length];
      for (int i = 0; i < names.length; i++) { names[i] = constants[i].name(); }
      throw new TypeConversionException(
        String.format("expected one of %s (%s) but was '%s'", Arrays.asList(names), sensitivity, value)); }
  }
};
origin: remkop/picocli

private void printParser(ParserSpec parser, PrintWriter pw, String indent) {
  pw.printf("%sParserSpec:%n", indent);
  indent += "  ";
  pw.printf("%sseparator: '%s'%n", indent, parser.separator());
  pw.printf("%sendOfOptionsDelimiter: '%s'%n", indent, parser.endOfOptionsDelimiter());
  pw.printf("%sexpandAtFiles: %s%n", indent, parser.expandAtFiles());
  pw.printf("%satFileCommentChar: '%s'%n", indent, parser.atFileCommentChar());
  pw.printf("%soverwrittenOptionsAllowed: %s%n", indent, parser.overwrittenOptionsAllowed());
  pw.printf("%sunmatchedArgumentsAllowed: %s%n", indent, parser.unmatchedArgumentsAllowed());
  pw.printf("%sunmatchedOptionsArePositionalParams: %s%n", indent, parser.unmatchedOptionsArePositionalParams());
  pw.printf("%sstopAtUnmatched: %s%n", indent, parser.stopAtUnmatched());
  pw.printf("%sstopAtPositional: %s%n", indent, parser.stopAtPositional());
  pw.printf("%sposixClusteredShortOptionsAllowed: %s%n", indent, parser.posixClusteredShortOptionsAllowed());
  pw.printf("%saritySatisfiedByAttachedOptionParam: %s%n", indent, parser.aritySatisfiedByAttachedOptionParam());
  pw.printf("%scaseInsensitiveEnumValuesAllowed: %s%n", indent, parser.caseInsensitiveEnumValuesAllowed());
  pw.printf("%scollectErrors: %s%n", indent, parser.collectErrors());
  pw.printf("%slimitSplit: %s%n", indent, parser.limitSplit());
  pw.printf("%stoggleBooleanFlags: %s%n", indent, parser.toggleBooleanFlags());
}
origin: remkop/picocli

/** Sets whether the parser should ignore case when converting arguments to {@code enum} values. The default is {@code false}.
 * When set to true, for example, for an option of type <a href="https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html">java.time.DayOfWeek</a>,
 * values {@code MonDaY}, {@code monday} and {@code MONDAY} are all recognized if {@code true}.
 * <p>The specified setting will be registered with this {@code CommandLine} and the full hierarchy of its
 * subcommands and nested sub-subcommands <em>at the moment this method is called</em>. Subcommands added
 * later will have the default setting. To ensure a setting is applied to all
 * subcommands, call the setter last, after adding subcommands.</p>
 * @param newValue the new setting
 * @return this {@code CommandLine} object, to allow method chaining
 * @since 3.4
 */
public CommandLine setCaseInsensitiveEnumValuesAllowed(boolean newValue) {
  getCommandSpec().parser().caseInsensitiveEnumValuesAllowed(newValue);
  for (CommandLine command : getCommandSpec().subcommands().values()) {
    command.setCaseInsensitiveEnumValuesAllowed(newValue);
  }
  return this;
}
origin: hazelcast/hazelcast-jet

/** Sets whether the parser should ignore case when converting arguments to {@code enum} values. The default is {@code false}.
 * When set to true, for example, for an option of type <a href="https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html">java.time.DayOfWeek</a>,
 * values {@code MonDaY}, {@code monday} and {@code MONDAY} are all recognized if {@code true}.
 * <p>The specified setting will be registered with this {@code CommandLine} and the full hierarchy of its
 * subcommands and nested sub-subcommands <em>at the moment this method is called</em>. Subcommands added
 * later will have the default setting. To ensure a setting is applied to all
 * subcommands, call the setter last, after adding subcommands.</p>
 * @param newValue the new setting
 * @return this {@code CommandLine} object, to allow method chaining
 * @since 3.4
 */
public CommandLine setCaseInsensitiveEnumValuesAllowed(boolean newValue) {
  getCommandSpec().parser().caseInsensitiveEnumValuesAllowed(newValue);
  for (CommandLine command : getCommandSpec().subcommands().values()) {
    command.setCaseInsensitiveEnumValuesAllowed(newValue);
  }
  return this;
}
origin: hazelcast/hazelcast-jet

  @SuppressWarnings("unchecked")
  public Object convert(String value) throws Exception {
    if (commandSpec.parser().caseInsensitiveEnumValuesAllowed()) {
      String upper = value.toUpperCase();
      for (Object enumConstant : type.getEnumConstants()) {
        if (upper.equals(String.valueOf(enumConstant).toUpperCase())) { return enumConstant; }
      }
    }
    try { return Enum.valueOf((Class<Enum>) type, value); }
    catch (Exception ex) { throw new TypeConversionException(
        String.format("expected one of %s but was '%s'", Arrays.asList(type.getEnumConstants()), value)); }
  }
};
origin: info.picocli/picocli

@Test
public void testCommandSpecParserSetter() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  ParserSpec old = spec.parser();
  assertSame(old, spec.parser());
  assertFalse(spec.parser().collectErrors());
  assertFalse(spec.parser().caseInsensitiveEnumValuesAllowed());
  ParserSpec update = new ParserSpec().collectErrors(true).caseInsensitiveEnumValuesAllowed(true);
  spec.parser(update);
  assertSame(old, spec.parser());
  assertTrue(spec.parser().collectErrors());
  assertTrue(spec.parser().caseInsensitiveEnumValuesAllowed());
}
origin: hazelcast/hazelcast-jet

/** Returns whether the parser should ignore case when converting arguments to {@code enum} values. The default is {@code false}.
 * @return {@code true} if enum values can be specified that don't match the {@code toString()} value of the enum constant, {@code false} otherwise;
 * e.g., for an option of type <a href="https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html">java.time.DayOfWeek</a>,
 * values {@code MonDaY}, {@code monday} and {@code MONDAY} are all recognized if {@code true}.
 * @since 3.4 */
public boolean isCaseInsensitiveEnumValuesAllowed() { return getCommandSpec().parser().caseInsensitiveEnumValuesAllowed(); }
origin: remkop/picocli

@Test
public void testCommandSpecParserSetter() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  ParserSpec old = spec.parser();
  assertSame(old, spec.parser());
  assertFalse(spec.parser().collectErrors());
  assertFalse(spec.parser().caseInsensitiveEnumValuesAllowed());
  ParserSpec update = new ParserSpec().collectErrors(true).caseInsensitiveEnumValuesAllowed(true);
  spec.parser(update);
  assertSame(old, spec.parser());
  assertTrue(spec.parser().collectErrors());
  assertTrue(spec.parser().caseInsensitiveEnumValuesAllowed());
}
origin: remkop/picocli

/** Returns whether the parser should ignore case when converting arguments to {@code enum} values. The default is {@code false}.
 * @return {@code true} if enum values can be specified that don't match the {@code toString()} value of the enum constant, {@code false} otherwise;
 * e.g., for an option of type <a href="https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html">java.time.DayOfWeek</a>,
 * values {@code MonDaY}, {@code monday} and {@code MONDAY} are all recognized if {@code true}.
 * @since 3.4 */
public boolean isCaseInsensitiveEnumValuesAllowed() { return getCommandSpec().parser().caseInsensitiveEnumValuesAllowed(); }
picocliCommandLine$Model$ParserSpeccaseInsensitiveEnumValuesAllowed

Popular methods of CommandLine$Model$ParserSpec

  • separator
  • aritySatisfiedByAttachedOptionParam
  • collectErrors
  • limitSplit
  • posixClusteredShortOptionsAllowed
  • unmatchedOptionsArePositionalParams
  • splitQuotedStrings
  • trimQuotes
  • useSimplifiedAtFiles
  • atFileCommentChar
  • endOfOptionsDelimiter
  • expandAtFiles
  • endOfOptionsDelimiter,
  • expandAtFiles,
  • overwrittenOptionsAllowed,
  • stopAtPositional,
  • stopAtUnmatched,
  • toggleBooleanFlags,
  • unmatchedArgumentsAllowed,
  • <init>,
  • initFrom

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • setScale (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Notification (javax.management)
  • JOptionPane (javax.swing)
  • Runner (org.openjdk.jmh.runner)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now