/** * <p>Gives any arguments associated with the given option. If the option was given an argument type, the * arguments will take on that type; otherwise, they will be {@link String}s.</p> * * <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 arguments associated with the option; an empty list if no such arguments are present, or if the * option was not detected * @throws NullPointerException if {@code option} is {@code null} * @throws OptionException if there is a problem converting the option's arguments to the desired type; for * example, if the type does not implement a correct conversion constructor or method */ public <V> List<V> valuesOf( OptionSpec<V> option ) { requireNonNull( option ); List<String> values = optionsToArguments.get( option ); if ( values == null || values.isEmpty() ) return defaultValueFor( option ); AbstractOptionSpec<V> spec = (AbstractOptionSpec<V>) option; List<V> convertedValues = new ArrayList<>(); for ( String each : values ) convertedValues.add( spec.convert( each ) ); return unmodifiableList( convertedValues ); }
/** * <p>Gives any arguments associated with the given option. If the option was given an argument type, the * arguments will take on that type; otherwise, they will be {@link String}s.</p> * * <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 arguments associated with the option; an empty list if no such arguments are present, or if the * option was not detected * @throws NullPointerException if {@code option} is {@code null} * @throws OptionException if there is a problem converting the option's arguments to the desired type; for * example, if the type does not implement a correct conversion constructor or method */ public <V> List<V> valuesOf( OptionSpec<V> option ) { requireNonNull( option ); List<String> values = optionsToArguments.get( option ); if ( values == null || values.isEmpty() ) return defaultValueFor( option ); AbstractOptionSpec<V> spec = (AbstractOptionSpec<V>) option; List<V> convertedValues = new ArrayList<>(); for ( String each : values ) convertedValues.add( spec.convert( each ) ); return unmodifiableList( convertedValues ); }
/** * <p>Gives any arguments associated with the given option. If the option was given an argument type, the * arguments will take on that type; otherwise, they will be {@link String}s.</p> * * <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 arguments associated with the option; an empty list if no such arguments are present, or if the * option was not detected * @throws NullPointerException if {@code option} is {@code null} * @throws OptionException if there is a problem converting the option's arguments to the desired type; for * example, if the type does not implement a correct conversion constructor or method */ public <V> List<V> valuesOf( OptionSpec<V> option ) { ensureNotNull( option ); List<String> values = optionsToArguments.get( option ); if ( values == null || values.isEmpty() ) return defaultValueFor( option ); AbstractOptionSpec<V> spec = (AbstractOptionSpec<V>) option; List<V> convertedValues = new ArrayList<V>(); for ( String each : values ) convertedValues.add( spec.convert( each ) ); return unmodifiableList( convertedValues ); }
/** * <p>Gives any arguments associated with the given option. If the option was given an argument type, the * arguments will take on that type; otherwise, they will be {@link String}s.</p> * * <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 arguments associated with the option; an empty list if no such arguments are present, or if the * option was not detected * @throws NullPointerException if {@code option} is {@code null} * @throws OptionException if there is a problem converting the option's arguments to the desired type; for * example, if the type does not implement a correct conversion constructor or method */ public <V> List<V> valuesOf( OptionSpec<V> option ) { ensureNotNull( option ); List<String> values = optionsToArguments.get( option ); if ( values == null || values.isEmpty() ) return defaultValueFor( option ); AbstractOptionSpec<V> spec = (AbstractOptionSpec<V>) option; List<V> convertedValues = new ArrayList<V>(); for ( String each : values ) convertedValues.add( spec.convert( each ) ); return unmodifiableList( convertedValues ); }
/** * <p>Gives any arguments associated with the given option. If the option was given an argument type, the * arguments will take on that type; otherwise, they will be {@link String}s.</p> * * <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 arguments associated with the option; an empty list if no such arguments are present, or if the * option was not detected * @throws NullPointerException if {@code option} is {@code null} * @throws OptionException if there is a problem converting the option's arguments to the desired type; for * example, if the type does not implement a correct conversion constructor or method */ public <V> List<V> valuesOf( OptionSpec<V> option ) { ensureNotNull( option ); List<String> values = optionsToArguments.get( option ); if ( values == null || values.isEmpty() ) return defaultValueFor( option ); AbstractOptionSpec<V> spec = (AbstractOptionSpec<V>) option; List<V> convertedValues = new ArrayList<V>(); for ( String each : values ) convertedValues.add( spec.convert( each ) ); return unmodifiableList( convertedValues ); }