joptsimple.OptionSet.defaultValueFor()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(77)

本文整理了Java中joptsimple.OptionSet.defaultValueFor()方法的一些代码示例,展示了OptionSet.defaultValueFor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OptionSet.defaultValueFor()方法的具体详情如下:
包路径:joptsimple.OptionSet
类名称:OptionSet
方法名:defaultValueFor

OptionSet.defaultValueFor介绍

暂无

代码示例

代码示例来源:origin: net.sf.jopt-simple/jopt-simple

/**
 * <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 );
}

代码示例来源:origin: jopt-simple/jopt-simple

/**
 * <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 );
}

代码示例来源:origin: io.snappydata/gemfire-util

/**
 * <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 );
}

代码示例来源:origin: io.snappydata/gemfire-joptsimple

/**
 * <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 );
}

代码示例来源:origin: org.apache.geode/geode-joptsimple

/**
 * <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 );
}

相关文章