Tabnine Logo
AlreadySelectedException
Code IndexAdd Tabnine to your IDE (free)

How to use
AlreadySelectedException
in
org.apache.commons.cli

Best Java code snippets using org.apache.commons.cli.AlreadySelectedException (Showing top 11 results out of 315)

origin: commons-cli/commons-cli

/**
 * Set the selected option of this group to <code>name</code>.
 *
 * @param option the option that is selected
 * @throws AlreadySelectedException if an option from this group has 
 * already been selected.
 */
public void setSelected(Option option) throws AlreadySelectedException
{
  if (option == null)
  {
    // reset the option previously selected
    selected = null;
    return;
  }
  
  // if no option has already been selected or the 
  // same option is being reselected then set the
  // selected member variable
  if (selected == null || selected.equals(option.getKey()))
  {
    selected = option.getKey();
  }
  else
  {
    throw new AlreadySelectedException(this, option);
  }
}
origin: commons-cli/commons-cli

@Test
public void testTwoOptionsFromGroup() throws Exception
{
  String[] args = new String[] { "-f", "-d" };
  try
  {
    parser.parse( _options, args);
    fail( "two arguments from group not allowed" );
  }
  catch (AlreadySelectedException e)
  {
    assertNotNull("null option group", e.getOptionGroup());
    assertEquals("selected option", "f", e.getOptionGroup().getSelected());
    assertEquals("option", "d", e.getOption().getOpt());
  }
}
origin: EvoSuite/evosuite

  public void foo(){
    //here, at compile time we use the one in EvoSuite dependency, but not at runtime
    AlreadySelectedException e = new AlreadySelectedException(null);
    if(e.toString().equals("foo")){
      System.out.println("Only executed if SUT version is used, and not the one in EvoSuite's dependencies");
    }
  }
}
origin: OneBusAway/onebusaway-gtfs-modules

 System.exit(-2);
} catch (AlreadySelectedException ex) {
 System.err.println("Argument already selected: " + ex.getMessage());
 printHelp();
 System.exit(-2);
origin: OneBusAway/onebusaway-gtfs-modules

/*****************************************************************************
 * {@link Runnable} Interface
 ****************************************************************************/
public void run(String[] args) throws IOException {
 if (needsHelp(args)) {
  printHelp();
  System.exit(0);
 }
 try {
  CommandLine cli = _parser.parse(_options, args, true);
  runApplication(cli, args);
 } catch (MissingOptionException ex) {
  System.err.println("Missing argument: " + ex.getMessage());
  printHelp();
 } catch (MissingArgumentException ex) {
  System.err.println("Missing argument: " + ex.getMessage());
  printHelp();
 } catch (UnrecognizedOptionException ex) {
  System.err.println("Unknown argument: " + ex.getMessage());
  printHelp();
 } catch (AlreadySelectedException ex) {
  System.err.println("Argument already selected: " + ex.getMessage());
  printHelp();
 } catch (ParseException ex) {
  System.err.println(ex.getMessage());
  printHelp();
 } catch (Exception ex) {
  ex.printStackTrace();
 }
}
origin: cytoscape.corelibs/commons-cli-1-x-cytocape-custom

/**
 * set the selected option of this group to <code>name</code>.
 * @param opt the option that is selected
 * @throws AlreadySelectedException if an option from this group has
 * already been selected.
 */
public void setSelected(Option opt) throws AlreadySelectedException {
  // if no option has already been selected or the 
  // same option is being reselected then set the
  // selected member variable
  if ((this.selected == null) || this.selected.equals(opt.getOpt())) {
    this.selected = opt.getOpt();
  } else {
    throw new AlreadySelectedException("an option from this group has "
                      + "already been selected: '" + selected + "'");
  }
}
origin: commons-cli/commons-cli

@Test
public void testTwoLongOptionsFromGroup() throws Exception
{
  String[] args = new String[] { "--file", "--directory" };
  try
  {
    parser.parse(_options, args);
    fail( "two arguments from group not allowed" );
  }
  catch (AlreadySelectedException e)
  {
    assertNotNull("null option group", e.getOptionGroup());
    assertEquals("selected option", "f", e.getOptionGroup().getSelected());
    assertEquals("option", "d", e.getOption().getOpt());
  }
}
origin: org.cytoscape/cy-commons-cli

/**
 * set the selected option of this group to <code>name</code>.
 * @param opt the option that is selected
 * @throws AlreadySelectedException if an option from this group has
 * already been selected.
 */
public void setSelected(Option opt) throws AlreadySelectedException {
  // if no option has already been selected or the 
  // same option is being reselected then set the
  // selected member variable
  if ((this.selected == null) || this.selected.equals(opt.getOpt())) {
    this.selected = opt.getOpt();
  } else {
    throw new AlreadySelectedException("an option from this group has "
                      + "already been selected: '" + selected + "'");
  }
}
origin: sdedit/sdedit

/**
 * Set the selected option of this group to <code>name</code>.
 *
 * @param option the option that is selected
 * @throws AlreadySelectedException if an option from this group has 
 * already been selected.
 */
public void setSelected(Option option) throws AlreadySelectedException
{
  // if no option has already been selected or the 
  // same option is being reselected then set the
  // selected member variable
  if (selected == null || selected.equals(option.getOpt()))
  {
    selected = option.getOpt();
  }
  else
  {
    throw new AlreadySelectedException(this, option);
  }
}
origin: org.apache.commons/com.springsource.org.apache.commons.cli

/**
 * Set the selected option of this group to <code>name</code>.
 *
 * @param option the option that is selected
 * @throws AlreadySelectedException if an option from this group has 
 * already been selected.
 */
public void setSelected(Option option) throws AlreadySelectedException
{
  // if no option has already been selected or the 
  // same option is being reselected then set the
  // selected member variable
  if (selected == null || selected.equals(option.getOpt()))
  {
    selected = option.getOpt();
  }
  else
  {
    throw new AlreadySelectedException(this, option);
  }
}
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Set the selected option of this group to <code>name</code>.
 *
 * @param option the option that is selected
 * @throws AlreadySelectedException if an option from this group has 
 * already been selected.
 */
public void setSelected(Option option) throws AlreadySelectedException
{
  if (option == null)
  {
    // reset the option previously selected
    selected = null;
    return;
  }
  
  // if no option has already been selected or the 
  // same option is being reselected then set the
  // selected member variable
  if (selected == null || selected.equals(option.getKey()))
  {
    selected = option.getKey();
  }
  else
  {
    throw new AlreadySelectedException(this, option);
  }
}
org.apache.commons.cliAlreadySelectedException

Javadoc

Thrown when more than one option in an option group has been provided.

Most used methods

  • <init>
    Construct a new AlreadySelectedException for the specified option group.
  • getMessage
  • getOption
    Returns the option that was added to the group and triggered the exception.
  • getOptionGroup
    Returns the option group where another option has been selected.
  • toString

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getApplicationContext (Context)
  • getSupportFragmentManager (FragmentActivity)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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