/** * Add the specified option group. * * @param group the OptionGroup that is to be added * @return the resulting Options instance */ public Options addOptionGroup(OptionGroup group) { if (group.isRequired()) { requiredOpts.add(group); } for (Option option : group.getOptions()) { // an Option cannot be required if it is in an // OptionGroup, either the group is required or // nothing is required option.setRequired(false); addOption(option); optionGroups.put(option.getKey(), group); } return this; }
if (!group.isRequired()) if (!group.isRequired())
/** * Removes the option or its group from the list of expected elements. * * @param option */ private void updateRequiredOptions(Option option) throws AlreadySelectedException { if (option.isRequired()) { expectedOpts.remove(option.getKey()); } // if the option is in an OptionGroup make that option the selected option of the group if (options.getOptionGroup(option) != null) { OptionGroup group = options.getOptionGroup(option); if (group.isRequired()) { expectedOpts.remove(group); } group.setSelected(option); } }
/** * Removes the option or its group from the list of expected elements. * * @param opt */ private void updateRequiredOptions(Option opt) throws ParseException { // if the option is a required option remove the option from // the requiredOptions list if (opt.isRequired()) { getRequiredOptions().remove(opt.getKey()); } // if the option is in an OptionGroup make that option the selected // option of the group if (getOptions().getOptionGroup(opt) != null) { OptionGroup group = getOptions().getOptionGroup(opt); if (group.isRequired()) { getRequiredOptions().remove(group); } group.setSelected(opt); } } }
/** * Appends the usage clause for an OptionGroup to a StringBuffer. * The clause is wrapped in square brackets if the group is required. * The display of the options is handled by appendOption * @param buff the StringBuffer to append to * @param group the group to append * @see #appendOption(StringBuffer,Option,boolean) */ private static void appendOptionGroup(final StringBuffer buff, final OptionGroup group) { if (!group.isRequired()) { buff.append("["); } // for each option in the OptionGroup for (Iterator i = group.getOptions().iterator(); i.hasNext();) { // whether the option is required or not is handled at group level appendOption(buff, (Option) i.next(), true); if (i.hasNext()) { buff.append(" | "); } } if (!group.isRequired()) { buff.append("]"); } }
/** * Appends the usage clause for an OptionGroup to a StringBuffer. * The clause is wrapped in square brackets if the group is required. * The display of the options is handled by appendOption * @param buff the StringBuffer to append to * @param group the group to append * @see #appendOption(StringBuffer,Option,boolean) */ private static void appendOptionGroup(final StringBuffer buff, final OptionGroup group) { if (!group.isRequired()) { buff.append("["); } // for each option in the OptionGroup for (Iterator i = group.getOptions().iterator(); i.hasNext();) { // whether the option is required or not is handled at group level appendOption(buff, (Option) i.next(), true); if (i.hasNext()) { buff.append(" | "); } } if (!group.isRequired()) { buff.append("]"); } }
/** * Add the specified option group. * * @param group the OptionGroup that is to be added * @return the resulting Options instance */ public Options addOptionGroup(OptionGroup group) { Iterator options = group.getOptions().iterator(); if (group.isRequired()) { requiredOpts.add(group); } while (options.hasNext()) { Option option = (Option) options.next(); // an Option cannot be required if it is in an // OptionGroup, either the group is required or // nothing is required option.setRequired(false); addOption(option); optionGroups.put(option.getKey(), group); } return this; }
/** * Add the specified option group. * * @param group the OptionGroup that is to be added * @return the resulting Options instance */ public Options addOptionGroup(OptionGroup group) { Iterator options = group.getOptions().iterator(); if (group.isRequired()) { requiredOpts.add(group); } while (options.hasNext()) { Option option = (Option) options.next(); // an Option cannot be required if it is in an // OptionGroup, either the group is required or // nothing is required option.setRequired(false); addOption(option); optionGroups.put(option.getKey(), group); } return this; }
if (!group.isRequired()) if (!group.isRequired())
/** * Appends the usage clause for an OptionGroup to a StringBuilder. The clause * is wrapped in square brackets if the group is not required. The display of * the options is handled by appendOption * * @param buff * the StringBuilder to append to * @param group * the group to append * @see #appendOption(StringBuffer,Option,boolean) */ protected void appendOptionGroup(final StringBuilder buff, final OptionGroup group) { if (!group.isRequired()) { buff.append('['); } ArrayList<Option> optList = new ArrayList<>(group.getOptions()); Collections.sort(optList, getOptionComparator()); // for each option in the OptionGroup for (Iterator<?> i = optList.iterator(); i.hasNext();) { // whether the option is required or not is handled at group level appendOption(buff, (Option)i.next(), true); if (i.hasNext()) { buff.append(" | "); } } if (!group.isRequired()) { buff.append(']'); } }
/** * Add the specified option group. * * @param group the OptionGroup that is to be added * @return the resulting Options instance */ public Options addOptionGroup(OptionGroup group) { Iterator options = group.getOptions().iterator(); if (group.isRequired()) { requiredOpts.add(group); } while (options.hasNext()) { Option option = (Option) options.next(); // an Option cannot be required if it is in an // OptionGroup, either the group is required or // nothing is required option.setRequired(false); addOption(option); optionGroups.put(option.getKey(), group); } return this; }
/** * Add the specified option group. * * @param group the OptionGroup that is to be added * @return the resulting Options instance */ public Options addOptionGroup(OptionGroup group) { if (group.isRequired()) { requiredOpts.add(group); } for (Option option : group.getOptions()) { // an Option cannot be required if it is in an // OptionGroup, either the group is required or // nothing is required option.setRequired(false); addOption(option); optionGroups.put(option.getKey(), group); } return this; }
/** * Add the specified option group. * * @param group the OptionGroup that is to be added * @return the resulting Options instance */ public Options addOptionGroup(OptionGroup group) { Iterator<Option> options = group.getOptions().iterator(); if (group.isRequired()) { requiredOpts.add(group.toString()); } while (options.hasNext()) { Option option = options.next(); // an Option cannot be required if it is in an // OptionGroup, either the group is required or // nothing is required option.setRequired(false); addOption(option); optionGroups.put(option.getKey(), group); } return this; }
if (!group.isRequired()) if (!group.isRequired())
if (!group.isRequired()) if (!group.isRequired())
/** * Removes the option or its group from the list of expected elements. * * @param option */ private void updateRequiredOptions(Option option) throws AlreadySelectedException { if (option.isRequired()) { expectedOpts.remove(option.getKey()); } // if the option is in an OptionGroup make that option the selected option of the group if (options.getOptionGroup(option) != null) { OptionGroup group = options.getOptionGroup(option); if (group.isRequired()) { expectedOpts.remove(group); } group.setSelected(option); } }
/** * Removes the option or its group from the list of expected elements. * * @param opt */ private void updateRequiredOptions(Option opt) throws ParseException { // if the option is a required option remove the option from // the requiredOptions list if (opt.isRequired()) { getRequiredOptions().remove(opt.getKey()); } // if the option is in an OptionGroup make that option the selected // option of the group if (getOptions().getOptionGroup(opt) != null) { OptionGroup group = getOptions().getOptionGroup(opt); if (group.isRequired()) { getRequiredOptions().remove(group); } group.setSelected(opt); } } }
OptionGroup group = options.getOptionGroup(opt); if (group.isRequired()) { requiredOptions.remove(group);
OptionGroup group = options.getOptionGroup(opt); if (group.isRequired()) { requiredOptions.remove(group.toString());