@Override public String getMessage() { return "Found multiple arguments for option " + multipleOptionMessage() + ", but you asked for only one"; } }
@Override Object[] messageArguments() { return new Object[] { singleOptionString() }; } }
/** * Gives the argument associated with the given option. * * <p>This method recognizes only instances of options returned from the fluent interface methods.</p> * * @param <V> represents the type of the arguments the given option accepts * @param option the option to search for * @return the argument of the given option; {@code null} if no argument is present, or that option was not * detected * @throws OptionException if more than one argument was detected for the option * @throws NullPointerException if {@code option} is {@code null} * @throws ClassCastException if the arguments of this option are not of the expected type */ public <V> V valueOf( OptionSpec<V> option ) { requireNonNull( option ); List<V> values = valuesOf( option ); switch ( values.size() ) { case 0: return null; case 1: return values.get( 0 ); default: throw new MultipleArgumentsForOptionException( option ); } }
/** * Gives the argument associated with the given option. * * <p>This method recognizes only instances of options returned from the fluent interface methods.</p> * * @param <V> represents the type of the arguments the given option accepts * @param option the option to search for * @return the argument of the given option; {@code null} if no argument is present, or that option was not * detected * @throws OptionException if more than one argument was detected for the option * @throws NullPointerException if {@code option} is {@code null} * @throws ClassCastException if the arguments of this option are not of the expected type */ public <V> V valueOf( OptionSpec<V> option ) { requireNonNull( option ); List<V> values = valuesOf( option ); switch ( values.size() ) { case 0: return null; case 1: return values.get( 0 ); default: throw new MultipleArgumentsForOptionException( option ); } }
/** * Gives the argument associated with the given option. * * <p>This method recognizes only instances of options returned from the fluent interface methods.</p> * * @param <V> represents the type of the arguments the given option accepts * @param option the option to search for * @return the argument of the given option; {@code null} if no argument is present, or that option was not * detected * @throws OptionException if more than one argument was detected for the option * @throws NullPointerException if {@code option} is {@code null} * @throws ClassCastException if the arguments of this option are not of the expected type */ public <V> V valueOf( OptionSpec<V> option ) { ensureNotNull( option ); List<V> values = valuesOf( option ); switch ( values.size() ) { case 0: return null; case 1: return values.get( 0 ); default: throw new MultipleArgumentsForOptionException( option.options() ); } }
@Override public String getMessage() { return "Found multiple arguments for option " + multipleOptionMessage() + ", but you asked for only one"; } }
@Override Object[] messageArguments() { return new Object[] { singleOptionString() }; } }
/** * Gives the argument associated with the given option. * * <p>This method recognizes only instances of options returned from the fluent interface methods.</p> * * @param <V> represents the type of the arguments the given option accepts * @param option the option to search for * @return the argument of the given option; {@code null} if no argument is present, or that option was not * detected * @throws OptionException if more than one argument was detected for the option * @throws NullPointerException if {@code option} is {@code null} * @throws ClassCastException if the arguments of this option are not of the expected type */ public <V> V valueOf( OptionSpec<V> option ) { ensureNotNull( option ); List<V> values = valuesOf( option ); switch ( values.size() ) { case 0: return null; case 1: return values.get( 0 ); default: throw new MultipleArgumentsForOptionException( option.options() ); } }
@Override public String getMessage() { return "Found multiple arguments for option " + multipleOptionMessage() + ", but you asked for only one"; } }
/** * Gives the argument associated with the given option. * * <p>This method recognizes only instances of options returned from the fluent interface methods.</p> * * @param <V> represents the type of the arguments the given option accepts * @param option the option to search for * @return the argument of the given option; {@code null} if no argument is present, or that option was not * detected * @throws OptionException if more than one argument was detected for the option * @throws NullPointerException if {@code option} is {@code null} * @throws ClassCastException if the arguments of this option are not of the expected type */ public <V> V valueOf( OptionSpec<V> option ) { ensureNotNull( option ); List<V> values = valuesOf( option ); switch ( values.size() ) { case 0: return null; case 1: return values.get( 0 ); default: throw new MultipleArgumentsForOptionException( option.options() ); } }
List<String> optionList = new ArrayList<String>(1); optionList.add(string); ce = processException(new MultipleArgumentsForOptionException(optionList, joptOptionSet)); } else if ((arguments.size() == 1 && !(option.getConverter() instanceof MultipleValueConverter)) || option.getValueSeparator() == null) { optionSet.put(option, arguments.get(0).toString().trim());
List<String> optionList = new ArrayList<String>(1); optionList.add(string); ce = processException(new MultipleArgumentsForOptionException(optionList, joptOptionSet)); } else if ((arguments.size() == 1 && !(option.getConverter() instanceof MultipleValueConverter)) || option.getValueSeparator() == null) { optionSet.put(option, arguments.get(0).toString().trim());