/** * 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; }
Iterator<Option> iter = getOptions().iterator();
List<Option> optList = new ArrayList<Option>(group.getOptions()); if (getOptionComparator() != null)
private void addOption(Options theOptions, OptionGroup theOptionGroup, boolean theRequired, String theOpt, String theLongOpt, boolean theHasArgument, String theArgumentName, String theDescription) { Option option = createOption(theRequired, theOpt, theLongOpt, theHasArgument, theDescription); if (theHasArgument && isNotBlank(theArgumentName)) { option.setArgName(theArgumentName); } if (isNotBlank(theOpt)) { if (theOptions.getOption(theOpt) != null) { throw new IllegalStateException("Duplicate option: " + theOpt); } if (theOptionGroup != null && theOptionGroup.getOptions().stream().anyMatch(t -> theOpt.equals(t.getOpt()))) { throw new IllegalStateException("Duplicate option: " + theOpt); } } if (isNotBlank(theLongOpt)) { if (theOptions.getOption(theLongOpt) != null) { throw new IllegalStateException("Duplicate option: " + theLongOpt); } if (theOptionGroup != null && theOptionGroup.getOptions().stream().anyMatch(t -> theLongOpt.equals(t.getLongOpt()))) { throw new IllegalStateException("Duplicate option: " + theOpt); } } if (theOptionGroup != null) { theOptionGroup.addOption(option); } else { theOptions.addOption(option); } }
StringBuffer buff = new StringBuffer(); Iterator iter = getOptions().iterator();
/** * 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; }
StringBuffer buff = new StringBuffer(); Iterator iter = getOptions().iterator();
Iterator iter = getOptions().iterator();
/** * 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; }
Iterator iter = getOptions().iterator();
/** * 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; }
/** * 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("]"); } }
Iterator<Option> iter = getOptions().iterator();
List optList = new ArrayList(group.getOptions()); Collections.sort(optList, getOptionComparator());
/** * 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(']'); } }
List optList = new ArrayList(group.getOptions()); Collections.sort(optList, getOptionComparator());
List<Option> optList = new ArrayList<Option>(group.getOptions()); if (getOptionComparator() != null)