ArgumentParser { @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") public Boolean getBooleanValue(Option option) throws IllegalStateException { ensureCommandLineNotNull(); return commandLine.hasOption(option.getOpt()); } ArgumentParser(String applicationName); String getApplicationName(); Option addArgument(Option option, boolean required); Option addArgument(String opt, String longOpt, boolean hasArg, String description, boolean required); Collection getConfiguredOptions(); void parseArguments(String[] args, boolean failOnMissingRequiredOptions); void parseArguments(String[] args); String getUsageInformation(); @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") Boolean getBooleanValue(Option option); @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") Boolean getStringValueAsBoolean(Option option, Boolean defaultValue); @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.") String getStringValue(Option option); String getStringValue(Option option, String defaultValue); Integer getIntegerValue(Option option); Integer getIntegerValue(Option option, Integer defaultValue); Integer getIntegerValue(Option option, Integer defaultValue, Integer minValue, Integer maxValue); File getFileValue(Option option); File getFileValue(Option option, File defaultValue);  }
@Test public void testGetBooleanValue() throws ParseException { ArgumentParser argParser = new ArgumentParser(""); Option boolOpt = argParser.addArgument("b", "bool", false, "Some optional configuration flag", false); Boolean resultValue; final String shortBoolOpt = String.format("-%s", boolOpt.getOpt()); final String longBoolOpt = String.format("--%s", boolOpt.getLongOpt()); argParser.parseArguments(new String[] {}); resultValue = argParser.getBooleanValue(boolOpt); assertNotNull(resultValue); assertFalse(resultValue); argParser.parseArguments(new String[] {shortBoolOpt}); resultValue = argParser.getBooleanValue(boolOpt); assertNotNull(resultValue); assertTrue(resultValue); argParser.parseArguments(new String[] {longBoolOpt}); resultValue = argParser.getBooleanValue(boolOpt); assertNotNull(resultValue); assertTrue(resultValue); }